+ 1
How to get multiple integer and string input in single line in python. Please help with clear explanation đ
1 2 3 4 5 6 I used map function but not working it's showing error
3 Answers
+ 2
To get a list of ints (1 2 3 4 5 6) from the input you can do;
nums = list(map(int, input().split()))
for a list of strings:
strings = input().split()
0
I tried this one it's not working in old version(2.7)
0
That was for Python 3.
For Python 2.7 use;
nums = map(int, raw_input().split())
and
strings = raw_input().split()
map() in 2.7 returns a list instead of a map object so no need to convert here.