+ 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

23rd Nov 2020, 3:35 AM
Vicky
Vicky - avatar
3 odpowiedzi
+ 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()
23rd Nov 2020, 3:59 AM
ChaoticDawg
ChaoticDawg - avatar
0
I tried this one it's not working in old version(2.7)
23rd Nov 2020, 7:58 AM
Vicky
Vicky - avatar
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.
23rd Nov 2020, 8:13 AM
ChaoticDawg
ChaoticDawg - avatar