标签:记录
今日内容:
猜年龄游戏和游戏优化:
依照上次代码:
age = 22
guess_num = int(input("input your guess number:"))
if guess_number == age:
print("Congratulation,you got it!")
elif guess_number > age:
print("Think smaller!")
else:
print("Think bigger")
加入循环10次
age = 22
for i in range(10)
guess_num = int(input("input your guess number:"))
if guess_number == age:
print("Congratulation,you got it!")
elif guess_number > age:
print("Think smaller!")
else:
print("Think bigger")
10次中三次猜不中退出:
age = 22
for i in range(10)
if i < 3
guess_num = int(input("input your guess number:"))
if guess_number == age:
print("Congratulation,you got it!")
break#猜中退出全部循环
elif guess_number > age:
print("Think smaller!")
else:
print("Think bigger")
else:
print("To many attampts")
break
10次中三次猜不中继续重新猜:
age = 22
counter == 0
for i in range(10)
if counter < 3
guess_num = int(input("input your guess number:"))
if guess_number == age:
print("Congratulation,you got it!")
break#猜中退出全部循环
elif guess_number > age:
print("Think smaller!")
else:
print("Think bigger")
else:
#print("To many attampts")
#break
continue_confirm = input("Do you want to continue?")
if continue == "yes"
counter = 0
continue#跳出当前循环
else:
break
counter +=1#counter = counter +1
标签:记录
原文地址:http://12306114.blog.51cto.com/12296114/1878327