|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- times = 3
- temp = input("請輸入一個年份")
- year = int(temp)
- while times:
- while not temp.isdigit():
- print("輸入有誒,請重新輸入:")
- if year % 4 == 0 or year % 100 != 0:
- print(temp + "是閏年")
- else:
- if year % 400 == 0:
- print(temp + "是閏年")
- else:
- print(temp + "不是閏年")
- if times > 0:
- print("還能測試")
- else:
- print("機會用光,重新開啟吧")
- break
- times = times - 1
复制代码
我就想多求输入几次 不想 老是循环 那么累 结果 不加 break 就一次循环完了 加break 就直接跳出循环了 研究半小时了
屁哥 发表于 2018-1-6 14:20
這個運行了 上面是用and 的 下面是 用 or 编译 能帮忙解释解释 他俩的区别么
因为闰年的定义中的一种就是4的倍数且不是100的倍数
|
|