+ 1

Can someone explain why my return values are literally the input and not the answer?

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

8th Apr 2017, 10:17 PM
Castle Corporation
Castle Corporation - avatar
3 Answers
+ 11
1) you need to print what the function return so use print (add (num1, num2)) insted of add (num1, num2) print (num1 + num2) of course you need to change for every operator 2) convert the input to a integer because you can't calculate with strings
8th Apr 2017, 10:26 PM
Kamil
Kamil - avatar
+ 6
This is the way sololearn Code Playground works. Your code requires input. So before showing anything to the console You will see a popup box where you have to insert all the input in a go. Only after that, the console will show your data. Including your question. That's why you are seeing the input answer after you submit the input. But the result of the code is also there. Look careful and you will see it. Another thing. You code is not adding integers, but concatenating strings. if your input is a +, a 3 and a 4 you will get 34. to avoid that, convert the input to integer: value = int(input('insert your input:')) Hope I helped.
8th Apr 2017, 10:37 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 4
Hint: inputs in python are in string format. You need numbers ( int or float) . So find a way to convert your inputs to int or float. Could have given you the solution but this is how you will learn. â˜ș Good luck.
8th Apr 2017, 10:26 PM
Shraddha
Shraddha - avatar