+ 2

Inputs in one line !?

How can I to require inputs in one line ? For example: x = int (input('Insert a number major than 1: ') y = int (input ('Insert ... than 10: ') z = int (input('Insert ... than 100: ') In this case, the inputs should be writted: (example) 2 12 102 One by line. But I want multiples inputs in one line separated by spaces: (example) 2 12 102

12th Sep 2017, 9:27 PM
▲TopGun ▲
▲TopGun ▲ - avatar
2 Réponses
+ 8
Try this: a, b, c = input('Enter nums separated with a space:').split(' ') print(a, b, c)
12th Sep 2017, 9:37 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
As kuba said, you can use multiple values by seperating them with a comma. There is another way that isn't as good, but may be a good learning opportunity: print(a, end = ' ') print(b, end = ' ') print(c) Print statements outomatically end with a next line (/n). In order to make them end with something else, you can make "end =" and put any string after it. I made it end with a string with a space.
12th Sep 2017, 11:45 PM
chessmonster
chessmonster - avatar