关于作者

Discuss / Python / SyntaxError: invalid syntax?

SyntaxError: invalid syntax?

问题来源

Chefback

#1 Created at ...

L = [] n = 1 while n <= 99: L.append(n) n = n + 2 print(L)

错误是SyntaxError: invalid syntax??

安迪博德

#2 Created at ...

你这段代码,如果全部粘贴到cmd中,会报错,因为会把print语句当成了while的内部语句(三个点),而又缺少缩进。 我也是试了半天才发现的……

失业你介夫

#3 Created at ...

2#说得对!


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.