1 2 3 4 5 6 7 8 9 10 11 12 13 |
name = input ( "Your name, plz:" ) file = "temp.txt" with open ( file , "w" ) as file : file .write(name + "\n" ) file = "temp.txt" while True : name = input ( "Your name, again:" ) if name = = "": break else : with open ( file , "a" ) as file : file .write(name + "\n" ) |
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-44303ce02481> in <module>
10 break
11 else:
---> 12 with open(file, "a") as file:
13 file.write(name + "\n")
TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
---------------------------------------------------------------------------
But I really don't know where the syntax error is...
Does anyone help me solve this issue? Thank you very much.