+ 1

Cant we use input function multiple times in a program?

I typed a code containing input function one after the other and compiler showed error compiling it. https://code.sololearn.com/cR4QA1PV7Oqj/?ref=app

11th Nov 2017, 7:39 AM
Ritwek Jaiswal
2 odpowiedzi
+ 9
The problem is that u are trying to assign the print function to a variable. Print function returns "None" meaning it doesn't actually return anything definitely doesn't return what it prints. So when u try to add "None" to "None" u will get an exception/error If what u are trying to do is add the inputs , do; s = input() t = input() result = int(s) + int(t) #have to convert s and t to integers since input() takes a string print(result)
11th Nov 2017, 8:05 AM
David Akhihiero
David Akhihiero - avatar
+ 8
Yeah. Separate multiple inputs with a new line.
11th Nov 2017, 7:43 AM
qwerty
qwerty - avatar