0

How to read a list

g=input is list

14th Aug 2017, 6:22 AM
Yash Ranka
2 Antworten
+ 1
if input is like "123" : li = list(input()) else if input is like "1 2 3" : li = input().split(' ')
14th Aug 2017, 9:07 AM
clement
clement - avatar
0
Depends on how you want your input to be and what type etc, but here are a few ideas. To make the input '1234' into a list ['1', '2', '3', '4'] simply do: g = list(input()) to make the input '1 2 3 4' into a list [1, 2, 3, 4] g = [int(x) for x in input().split()] or g= list(map(int, input().split()))
14th Aug 2017, 6:45 AM
ChaoticDawg
ChaoticDawg - avatar