比较while语句中的变量python语法错误

时间:2017-06-13 20:04:46

标签: python variables while-loop

嗨,我对Python很陌生,但以前用其他基于C的语言编程。我一直遇到语法错误,但我无法弄清楚它的含义。

x = 1
Primary = 0
Secondary = 0

while x != 0:
    Primary + 1
    while Secondary <= Primary
        Ed.PlayBeep()
        Secondary + 1
    Secondary = 0

2 个答案:

答案 0 :(得分:2)

添加:

while Secondary <= Primary:
   ...

另外,您的意思是Primary += 1Secondary += 1吗?您正在递增这些值但不指定它们。

答案 1 :(得分:0)

你在第二次丢失冒号,它应该去:

    while Secondary <= Primary: