循环时在过程i之后添加增量有什么区别



这两个代码的区别是什么,我在第一个片段上得到无限循环

while (e <5):
print("hello)
e = e+1

第二个代码段中的正则while循环

while (e <5):
e = e+1
print("hello)

这两个代码片段都按预期工作。您可能在第一个代码片段中存在缩进问题。

e = 0
while e < 5:
print("hello")
e = e + 1
e = 0
while e < 5:
e = e + 1
print("hello")

相关内容

最新更新