1

colab or python ide is not recognize the or statement. If I run one statement, it checks and prompts me to enter the correct one. but if I add the next expression with the "or operator", it just keeps prompting me for the correct info even when its correct.

salesperson_num = input ("Please enter the salesperson's ID number: ")
sales_amt = float (input ("Please enter sales amount: "))
class_type = int (input ("Please enter a class type for the salesperson: "))

while class_type !=1 or class_type !=2:
    class_type = int(input("Please enter class a correct class: Class 1 , 2: "))

1 Answers1

0

You should use logic and to indicate that it is neither 1 nor 2:

while class_type != 1 and class_type != 2:
    ...

This is equivalent to:

while not (class_type == 1 or class_type == 2):
    ...
Mechanic Pig
  • 6,756
  • 3
  • 10
  • 31
  • what if i wanted to test if they are true, it was still not recognizing both expression. only when i add 1. so while class_type == 1 or class_type == 2: print("You are a sales person) – CONRADINE POWELL Apr 29 '22 at 17:28
  • @CONRADINEPOWELL Can you update your question and explain your new question with specific code? – Mechanic Pig Apr 30 '22 at 02:52