import random
secret=random.randint(1,10)#生成1到10的整型随机数
print("-----------------Guess number game------------------")
temp=input("Please input a number,you have 3 chances in total:")
number=int(temp)
chance = 2
if number==secret:
print("awesome,you got the anwser 1st time")
print("congratulations")
else:
while chance>0 or number==secret:
if number<secret:
print("too small, " + "you only have " + str(chance) + " chance now")
elif number>secret:
print("too big, " + "you only have " + str(chance) + " chance now")
else :
print("congratulations")
break
chance = chance - 1
temp = input("Please input a new number:")
number = int(temp)
print("Game Over")
=============
pyzao.jpg
网友评论