+ 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")
6 Respuestas
+ 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.
+ 1
if i run your code and i put suma in the second input suma it still print all the ifs.
+ 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")
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)