python 'or' is not working with while
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | print ('Welcome to Calculator') a = int(input('Enter your first value')) b = int(input('Enter your second value')) print ('''Addition - type 1 Subtraction - type 2 Multiplication - type 3 Division - type 4''') procedure = input('Enter a option') while (procedure != '1') or (procedure != '2') or (procedure != '3') or (procedure != '4'): procedure = input('Please choose the correct option') def process (): if procedure == '1': print (a+b) elif procedure == '2': print(a-b) elif procedure == '3': print (a*b) elif procedure == '4': print (a/b) else: print('There is some error in code') process () |
在这里,我希望每当过程的值不是1,2,3,4时,循环继续,但在此循环继续。 请告诉错误如何正确执行
用AND替换OR,然后查看结果。
想到AND(union(union))和OR(∩(intersection))的意思以及你写的条件,你一定会明白什么是错的......