這裏是我的代碼如何使Python中的猜謎遊戲,我掙扎
import random
print ('hello')
print ('my name is IB what is your name')
mn = input()
print ('it is good to meet you ' + mn+ ' I am thinking of a nomber 1 to
100')
it = 1
jojm = random.randint (1, 100)
print ('guess')
guess =input()
while it < 100:
if guess == jojm:
print ('game over ')
break
elif guess < jojm: #it keeps saying the problem is here
print ('to low')
print ('guess')
elif guess > jojm:
print ('to high')
print ('guess')
it = it + 1
print =it
我不知道該怎麼辦,請幫助我需要它,如果有人可以幫助請不要
有沒有真正的理由循環100次。用戶可能猜兩次相同的號碼或猜測1-100範圍以外的號碼。你可能會改善,只是做一個無限循環。 「雖然是真的:」當他們做對了的時候就休息了。你可以按ctrl + c來逃避循環。 –