-1
print("Example intro.")

answer = input("Write one, two, three, four or five (caps or no caps.)").lower().strip()

if answer == "one" or "One" or "ONE":
    print("1")                      
    
if answer == "two" or "Two" or "TWO":
   print("2")

if answer == "three" or "Three" or "THREE":
    print("3")

if answer ==  "four" or "Four" or "FOUR":
    print ("4")

if answer == "five" or "Five" or "FIVE":
    print ("5")
    

When you run the code it shows 1 2 3 4 5 as the result for all of the answers. Please tell me howe to fix this because Friday 14th October 2022 (GMT) is my deadline.

(This isn't the full script BTW)

  • To solve it yourself simplify things: `if answer == "one":`. By the way, that would be sufficient because of `lower`. You are missing `(answer = ...) or ((answer = ...)`. – Joop Eggen Oct 10 '22 at 18:57

1 Answers1

0

In python any non-zero value evaluates to true.

# the "One" by itself evaluates to true

if answer == "one" or "One" or "ONE":
    print("1")    

needs to be rewritten as

if (answer == "one") or (answer == "One") or (answer == "ONE"):
    print("1")    
Eric Yang
  • 2,678
  • 1
  • 12
  • 18