0

I was wondering why I can't use the "and" statement in my code here. I want it so that people can type either "1" or "Add" and same with multiply, but it simply doesn't work.
It's just a basic calculator. I'm using the basic Python program.

calcUnit = input("Choose between Add(1) or Multiply(2) :")

if calcUnit == **"Add" and "1":**

  print("You choose Add!")
  num1 = input("First Number :")
  num2 = input("Second Number :")
  result = float(num1) + float(num2)
  print("Result:",result)

elif calcUnit == **"Multiply" and "2":**

  print("You choose Multiply!")
  num1 = input("First Number :")
  num2 = input("Second Number :")
  result = float(num1) * float(num2)
  print("Result:",result)

else:
  print("Welp shiii")
Don Branson
  • 13,631
  • 10
  • 59
  • 101

1 Answers1

1

Because you need or. Something can't be "Add" and "1" at the same time, can it? And by the way is written this way

if calcUnit == "Add" or calcUnit == "1":

or

if calcUnit in ['Add', '1']:
Ursus
  • 29,643
  • 3
  • 33
  • 50