Suma de variables | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Suma de variables

Hola, llevo haciendo una calculadora un tiempo, pero cuando uso la función sum(x+y) (x e y son variables input) y le doy a print, el resultado es x y en lugar de su suma. ¿Alguien sabe como solucionarlo?

9th Dec 2020, 5:19 PM
Victor Aguilera Arenas
Victor Aguilera Arenas - avatar
2 Answers
+ 2
a = int(input()) b = int(input()) print(sum([a,b]))
9th Dec 2020, 5:30 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Victor Aguilera Arenas , maybe the problem is that you read both values as strings instead of int. Without your code it's hard to guess. But if I guess it right, read the values this way: x = int(input()), y = int(input()).
9th Dec 2020, 5:23 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar