我正在做一項任務,我不太確定如何從用戶那裏添加輸入值,假設他們都是整數。我試圖用一個while循環來做這件事,但它沒有解決。有沒有更好的方法可以解決這個問題?由於我如何獲得用戶輸入(int)總和
number = 10
guessed = False
Sum = 0
while guessed == False:
userInput= int(input("Please enter an integer: "))
value = userInput + Sum
print(value)
while循環是解決此問題的有效策略的一部分。發佈你的代碼,你會得到幫助。 – mhawke 2014-09-27 04:22:49
@RafaelBarros數= 10 猜到=假 薩姆= 0 而猜測==題: userInput = INT(輸入( 「請輸入一個整數:」)) 值= userInput +薩姆 打印(值) – 2014-09-27 04:25:07
@ mhawke你能看到它,我做了一個編輯 – 2014-09-27 04:30:54