Discuss / Python / 4。疑问?尝试了老师的代码,为何报错?

4。疑问?尝试了老师的代码,为何报错?

Topic source

CliffVon

#1 Created at ... [Delete] [Delete and Lock User]

4 L = ['Bart', 'Lisa', 'Adam'] for name in L: print('Hello,%s!' %name)

尝试了老师的代码,为何报错?

n = 1 while n <= 100: ... if n > 10: # 当n = 11时,条件满足,执行break语句 ... break # break语句会结束当前循环 ... print(n) ... n = n + 1 ... print('end') File "<stdin>", line 6 print('end') ^ SyntaxError: invalid syntax

aaasd21

#2 Created at ... [Delete] [Delete and Lock User]

print('end')缩进了

L = ['Bart', 'Lisa', 'Adam'] for name in L: print('Hello,%s!' %name)

这代码没错啊,我这边能够运行出来


  • 1

Reply