簡體   English   中英

變量名給出語法錯誤(Python)

[英]Variable name gives Syntax error (Python)

我制作的一個簡單程序有問題。

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

你錯過了一個) ,右括號,這里:

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

應該

    num1 = float(raw_input ("Please enter a number:"))
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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM