求一个python的编程,求大神帮助啊。。

2024-12-30 04:54:00
推荐回答(1个)
回答1:

import random
number=random.randint(1,100)
count=0
while (1):
inputnumber=input("Enter a number between 1 - 100:\n")
try:
inputnum=int(inputnumber)
except:
print('Formant your input string to a number error\n')
count=count+1
if inputnum print('Guess is too low\n')
elif inputnum>number:
print('Guess is too high\n')
else:
print('Congratulations! You get the answer. Times that you try to guess the number:', count)
break
print('Congratulations! You get the answer.\n')