Jan-16-2019, 05:26 PM
Hi.
I'm just a beginner, and I have a problem that I couldn't understand the reason.
when I tried to run on windows command prompt, it was successful.
On the other hand, on python interpreter (Python3.7.2), it had a syntax error like below.
I'm just a beginner, and I have a problem that I couldn't understand the reason.
f = open ("C:/doit/newfile.txt", 'w') for i in range(1,11): data = "%d line. \n" % i f.write(data) f.close()I was practising file input and output.
when I tried to run on windows command prompt, it was successful.
On the other hand, on python interpreter (Python3.7.2), it had a syntax error like below.
>>> f = open ("C:/doit/newfile.txt", 'w') >>> for i in range(1,11): ... data = "%d line. \n" % i ... f.write(data) ... f.close() File "<stdin>", line 4 f.close() ^ SyntaxError: invalid syntaxPlease let me know the reason.