luck_num = 10 num = 0 while luck_num != num: num = int(input('please input you num:')) if num > luck_num: print('Greater than lucknum') elif num < luck_num: print('Less than lucknum') print('This number is lucknum') for i in range(3): num = int(input('please input you number:')) if num > luck_num: print('Greater than lucknum') elif num < luck_num: print('Less than lucknum') else: print('Yes this number is lucknumber') break else: # 正常执行完循环的话,执行里面语句,非正常的话跳过这个else print('Try many,only three') #多层嵌套循环 for i in range(5): for m in range(10): if m < 5: continue if i > 3: break print(str(m) + ' ' + str(i)) else:#正常循环结束才执行else里面的代码 continue break