Why the if lines in this program doesn't work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why the if lines in this program doesn't work?

#Calculadora Amable Nombre = input("Sea bienvenido usuario: ") print("Que operacion deseas realizar "+ Nombre + " ?: \n Suma \n Resta \n Multiplicacion \n Division") operacion = input() if operacion == "suma" or "Suma": print("correcto") if operacion == "resta" or "Resta": print("correctos") if operacion == "multiplicacion" or "Multiplicacion": print("correctoss") if operacion == "division" or "Division": print("correctos")

28th Dec 2017, 12:17 AM
Fran Arenas Afán
Fran Arenas Afán - avatar
4 Answers
+ 1
i have tried it with tab without using spaces but it still doesn't work, i think it is and identitation error but i can't fix it. The problem is that if is always true.
28th Dec 2017, 12:38 AM
Fran Arenas Afán
Fran Arenas Afán - avatar
+ 1
if i run your code and i put suma in the second input suma it still print all the ifs.
28th Dec 2017, 12:46 AM
Fran Arenas Afán
Fran Arenas Afán - avatar
+ 1
i have fix the problem. #Calculadora Amable Nombre = input("Sea bienvenido usuario: ") print("Que operacion deseas realizar "+ Nombre + " ?: \n Suma \n Resta \n Multiplicacion \n Division") operacion = input() if operacion == "suma" or operacion=="Suma": print("correctoasdasdas") if operacion == "resta" or operacion=="Resta": print("correctos") if operacion == "multiplicacion" or operacion=="Multiplicacion": print("correctoss") if operacion == "division" or operacion=="Division": print("correcto")
28th Dec 2017, 12:51 AM
Fran Arenas Afán
Fran Arenas Afán - avatar
0
1. Needs 2 inputs. e.g.: 9 Suma 2. operacion == “suma” or “Suma” :returns true. Must use: operacion == “suma” or operacion ==“Suma” 3. Have questions, test by printing out condition e.g.: print (operacion == “suma” or “Suma” ) print (operacion == “suma” or operacion == “Suma)
28th Dec 2017, 12:50 AM
H Chiang