#猜数字 import random num_rd=random.randint(0,100) count=1 while 1<=count<=10: num_ip=input('请输入0---100之间的整数:') if num_ip.isdigit(): num=int(num_ip) if num==num_rd: print('用了'+str(count)+'次猜对了') break elif num<num_rd: print('猜小了') else: print('猜大了') elif num_ip=='' and count<10: print('不能输入空值,请重新输入') elif not num_ip.isdigit() and count<10: print('请重新输入,必须是0---100之间的整数') else: print('浪费了'+str(count)+'次机会,也没猜对') break count+=1
呕心沥血写的python猜数字
猜你喜欢
转载自www.cnblogs.com/tuobei/p/9390012.html
今日推荐
周排行