for循环及用for循环写猜年龄游戏

for循环:

for i in  range(0,10,2):
print("loop",i)


for循环写猜年龄:

age_of_XueKe=18

for i in range(3):
age = int(input("age:"))
if age == age_of_XueKe:
print("Yes,you got it!")
break
elif age >age_of_XueKe:
print("Think smaller!")
else:
print("Think bigger!")
else:
print("You have tried too many times...")

猜你喜欢

转载自www.cnblogs.com/shmilymima/p/9265590.html