AttributeError: '_io.TextIOWrapper' object has no attribute 'lower' for txt file
<p>Here is my code (A pig <strong>Latin translator</strong> from a text file):   </p>

<pre><code>f = open('Assignment_4.txt', 'r+')

for line in f:
    print(line)

def pigLatin():
    var = 'ay'
    wordL = f.lower()
    firstLetter = wordL[0]
    pigLatin = wordL + firstLetter + var
    pigLatin = pigLatin[1:]
    print(pigLatin)
</code></pre>

<p>It works for defined strings but won't for the file. Help is appreciated!</p>

<p>The error is quite right - file objects don't have a <code>lower()</code> method - before you can use your function you need to <code>read</code> a line of text from your file and <code>split</code> it into separate words. (Note that it is never a good idea to use the same name for a variable and a method as it can cause confusion.)</p>

python