python中for循环
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python中for循环相关的知识,希望对你有一定的参考价值。
1、打印0-9 十个数字
for i in range(10):
print(i)
2、打印偶数:
for i in range(0,10,2):
print(i)
3、if判断中猜游戏,升级(只能猜三次,超过三次没猜对,提示退出)
_age = 18
for i in range(3):
guess_age = int(input("guess_age:"))
if guess_age == _age:
print("GoodLuck!")
break
elif guess_age > _age:
print("cai da le ")
else:
print("cai xiao le ")
else:
print("chao guo san ci qing tui chu!!!")
以上是关于python中for循环的主要内容,如果未能解决你的问题,请参考以下文章