def read_lines():
readFileName = "readfile.txt"
f = open(readFileName, 'r+')
contents = f.read()
... # and so on
read_lines()
When I run this, I get an error:
f = open(readFileName, 'r+')
UnboundLocalError: local variable 'open' referenced before assignment
This means that further down in your function you create a variable called open
:
open = ...
Rename it so that it doesn't clash with the built-in function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With