I'm wondering why I got the NameError: name 'file' is not defined in python 3 when calling a function?
def func(file):
for file in os.listdir(cwd):
if file.endswith('.html'):
f = open(file, "r+")
....
f = open(file, "w")
f.write(text)
f.close()
func(file)
and maybe another simple example:
def func(hello):
print('Hello')
func(hello)
I also got the same error NameError: name 'hello' is not defined. I don't quite understand why this syntax is not compatible with Python3? Thank you very much!