+ 1
why I can't do an operation in a single input(2+2 3-2 etc). I need it.
2 Réponses
+ 1
Hi, i looked at your code and there a few mistakes :
- line 9 : you can't assign a variable to be equal to a method (like print in your example), you have to write : a = str(input)
- line 12 : same case, write : resultado = 'x es igual a ' + a
and the print it or print('x es igual a ' + a)
- the method you are looking for is "eval" (see this : https://docs.python.org/3/library/functions.html#eval)
- Your code should look like this :
#Progama de ecuaciones
print("Escribe tu ecuación")
a = str(eval(input()))
print('x es igual a '+a)
Hope this helps,
Cheers
0
thank you