+ 1

why I can't do an operation in a single input(2+2 3-2 etc). I need it.

https://code.sololearn.com/cE8Mpqtb6gj9/?ref=app

17th Sep 2018, 11:22 PM
Artur Spain 🇪🇸
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
17th Sep 2018, 11:40 PM
Nicolas Bonnet
Nicolas Bonnet - avatar
0
thank you
17th Sep 2018, 11:42 PM
Artur Spain 🇪🇸