0

我制作的一个简单程序有问题。

num2 = 0
num1 = 1
print ("Enter a number one after another to sum them up, and when you're done type 0")
while num1 != 0:
    num1 = float(raw_input ("Please enter a number:")
    num2 += num1
if num1 == 0:
    print ("The sum of the numbers is:" + str(num2))

由于某种原因,该行num2 += num1给了我一个语法错误num2

4

2 回答 2

3

你错过了一个 ),右括号,在这里:

    num1 = float(raw_input ("Please enter a number:")

应该

    num1 = float(raw_input ("Please enter a number:"))
于 2013-04-03T12:05:50.543 回答
0
num = (int(input('pick a number to find if it is prime')
div = 2
while num !% div or div != num-1 
    f=num/div
    if num % div :
        print('no as ' ,num, 'is divisible by ',div)
        div = 2
    else:
        div=div+1
于 2020-08-14T14:21:34.783 回答