想加q同时满足下面运行条件,但是一加q都不行了,怎么同时满足Q和q等功效啊?
您的while循环的条件存在问题:currency_str_value != 'Q' or 'q'。这行代码分解后应该分为:
①currency_str_value != 'Q'
or
②'q'
而第2个条件'q'总是视为True,因此会一直循环下去。如果要更改,可以这样:
while currency_str_value not in ('Q', 'q'):
同学,q不是这么加的,你得while str!=‘Q’ or str!='q'啊
两种方式
第一种
while currency_str_value not in ('Q', 'q'):
第二种
while currency_str_value != 'Q' and currency_str_value != 'q':
推荐使用第一种
望采纳,谢谢
将用户输入的大写的Q转为q,只判断q就行了
if currency_str_value=="Q":
currency_str_value=currency_str_value.lower()
while currency_str_value =="q":
pass
i=0上面添加一行 currency_str_value=currency_str_value.lower() 就可以,将获取的输入转化为小写,后面判断只要写小写q就OK