遊戲要求用戶輸入1
和5
之間的數字,並查看它們是否與計算機隨機猜測相匹配。Python初學者(猜測隨機數字遊戲)
當我得到if
else
聲明時,我的代碼似乎無法正常工作,並且無法解決問題。
from random import randint
print "I am thinking of a number between 1 and 5";
print "What do you think the number is that I am thinking of",
guess = raw_input("> ")
cguess = (randint(1,5))
print "Your guess was", guess,
print "\nMine was", cguess,
if guess == cguess
print "Well done you win"
if guess != cguess
print "You lose"
你的代碼有多個問題,從基本的語法錯誤,常見的問題。請查看您的教學材料,而不是要求我們糾正您的猜測。 「 – TigerhawkT3
」似乎不起作用「不是一個問題。 – 2016-03-15 06:35:04