multiple inputs | Sololearn: Learn to code for FREE!


multiple inputs

I want to make a calculator in Python, how would have multiple inputs?

10/22/2018 7:58:17 PM


5 Answers

New Answer


var = input().split(" ") then you get a list of all inputs but the must be seperated with a space


Ok, Thanks! :)


you can also change the split("x") then you can seperate them with x instead of space you're welcome :)


You can also take each input separately by looping and saving the results in a list, for example: L=[] while True: number=input() if not number: break if number.isdigit(): L.append(int(number)) Like that you are flexible in how many inputs you take - it stops when the user just presses enter. (Taking input with a loop works well in real life, not on sololearn though. ;-))


var1 = input(“enter a number”) var2 = input(“enter a number”) etc.