鱼C论坛

 找回密码
 立即注册
查看: 3077|回复: 15

[已解决]这串代码有问题吗 为什么提示出错啊

[复制链接]
发表于 2020-9-19 16:24:58 | 显示全部楼层
  1. while not temb.isdigit() and 0 < temb < 100:  
复制代码

你这句是想写temb不能小于0 也不能大于100吧?
你现在写的这句翻译成人话就是 ,输入的值不是数字型字符串时,这个字符串要大于0并且小于100
输入的值都不是纯数字的字符串了,怎么比较大小呢。
改成这样试试


  1. count = True
  2. while count:
  3.     temb = input('请输入你的分数:')
  4.     if not temb.isdigit():
  5.         print('请输入纯数字')
  6.     else:
  7.         score = int(temb)
  8.         if 0 > score or score > 100:
  9.             print('请输入大于0且小于100的整数')
  10.         else:
  11.             break

  12. if 100 > score >= 90:
  13.     print('A')
  14. elif 90 > score >= 80:
  15.     print('B')
  16. elif 80 > score >= 60:
  17.     print('C')
  18. elif 60 > score >= 0:
  19.     print('D')
复制代码



小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-13 03:10

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表