|
发表于 2020-9-19 16:24:58
|
显示全部楼层
- while not temb.isdigit() and 0 < temb < 100:
复制代码
你这句是想写temb不能小于0 也不能大于100吧?
你现在写的这句翻译成人话就是 ,输入的值不是数字型字符串时,这个字符串要大于0并且小于100
输入的值都不是纯数字的字符串了,怎么比较大小呢。
改成这样试试
- count = True
- while count:
- temb = input('请输入你的分数:')
- if not temb.isdigit():
- print('请输入纯数字')
- else:
- score = int(temb)
- if 0 > score or score > 100:
- print('请输入大于0且小于100的整数')
- else:
- break
- if 100 > score >= 90:
- print('A')
- elif 90 > score >= 80:
- print('B')
- elif 80 > score >= 60:
- print('C')
- elif 60 > score >= 0:
- print('D')
复制代码
|
|