python代码的入门:小游戏制作;
加入时间函数,猜数字.
import time
import random
import random
age_of_oldboy=random.randint(20,50)
#print(age_of_oldboy)
count = 0
while count <3:
guess_age = int(input("guess age:") )
if guess_age == age_of_oldboy :
print("yes, you got it. ")
break
elif guess_age > age_of_oldboy:
print("think smaller...")
else:
print("think bigger!")
count +=1
if count == 3:
countine_confirm = input("do you want to keep guessing..?")
if countine_confirm != 'n':
count =0