If statements + input | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

If statements + input

a=input("What you wanna do ?") print () print ("Enter numbers") x=input("No. 1- ") y=input("No. 2- ") If a== multiplication print (int(x) * int(y)) What is the mistake and how do I verify ? I even wanna do with addition , subs ...

25th Mar 2020, 6:04 AM
Atharva Gambhir
Atharva Gambhir - avatar
1 Antwort
0
multiplication is not enclosed in quotes (""). So it will be taken as variable name. But there is no variable named 'multiplication'. So just replace multiplication with "multiplication", i.e. if a == "multiplication": Because 'a' is taking input as a string and you have to compare a string to a string.
25th Mar 2020, 6:36 AM
XXX
XXX - avatar