2024-10-05 11:16:09 发布
网友
x = Flase while !x : a = 0 print(a) a++ pass if a == 10: x = True else: continue
我在“a++”时出错。我使用的是visualstudio2013社区,它在“a++”之后和“pass”之前给我一条红色下划线
Python中没有++或这样的语法,但是您可以执行+= 1和{}。在
++
+= 1
你的程序有一些逻辑错误
x = False a = 0 # a should be initialized here. If it is initialized in loop it will be a never-ending loop while not x : print(a) a+=1 if a == 10: x = True else: continue
注意事项:
检查False上的拼写是否有误
False
不需要pass
pass
您应该在Python中使用not,而不是使用!
not
!
使用for和range:
for
range
Python不支持++。你能做到的
a = a + 1
Python中没有}。在
++
或这样的语法,但是您可以执行
+= 1
和{你的程序有一些逻辑错误
注意事项:
检查
False
上的拼写是否有误不需要
pass
您应该在Python中使用
not
,而不是使用!
使用
^{pr2}$for
和range
:Python不支持++。你能做到的
相关问题 更多 >
编程相关推荐