Python语法练习--for循环
来源:动视网
责编:小采
时间:2020-11-27 14:27:08
Python语法练习--for循环
Python语法练习--for循环:#!/usr/bin/env python # -*- coding:utf8 -*- age = 26 for i in range(3): intput = int(input("请猜猜我的年龄:")) if intput < age: print ("输入过小,请重新输入") elif intput
导读Python语法练习--for循环:#!/usr/bin/env python # -*- coding:utf8 -*- age = 26 for i in range(3): intput = int(input("请猜猜我的年龄:")) if intput < age: print ("输入过小,请重新输入") elif intput

#!/usr/bin/env python
# -*- coding:utf8 -*-
age = 26
for i in range(3):
intput = int(input("请猜猜我的年龄:"))
if intput < age:
print ("输入过小,请重新输入")
elif intput > age:
print ("输入过大,请重新输入")
elif intput == age:
print ("答案正确,游戏退出")
break
else:
print ("输入错误3次,游戏退出")
Python语法练习--for循环
Python语法练习--for循环:#!/usr/bin/env python # -*- coding:utf8 -*- age = 26 for i in range(3): intput = int(input("请猜猜我的年龄:")) if intput < age: print ("输入过小,请重新输入") elif intput