您好,登录后才能下订单哦!
条件判断与缩进,注意冒号
加次数限制
#猜数字
lucky_num = 19
input_num = -1
#次数限制
count = 0
#while lucky_num!=input_num and count < 3:
while count < 3:
input_num = int(input("please input your lucky_num:"))
if input_num < lucky_num:
print("please input big num")
elif input_num > lucky_num:
print("please input little num")
else:
print("great")
break
count += 1
print(count)
else:
print("too many counts!!!!")
注意缩进,python是对缩进敏感的语言
注释:ctrl+/
for循环
#次数限制
for i in range(3):
input_num = int(input("please input your lucky_num:"))
if input_num < lucky_num:
print("please input big num")
elif input_num > lucky_num:
print("please input little num")
else:
print("great")
break
else:
print("too many counts!!!!")
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。