+ 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
2 Réponses
+ 8
Try this:
a, b, c = input('Enter nums separated with a space:').split(' ')
print(a, b, c)
+ 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.