How to split a string into a list of digits in Python

2 Answers

0 votes
str = "5 8 2 1 0 6"

lst = str.split()

map_object = map(int, lst)

lst = list(map_object)

print(lst)






'''
run:

[5, 8, 2, 1, 0, 6]

'''

 



answered Feb 19, 2022 by avibootz
0 votes
str = "5 8 2 1 0 6"

lst = list(map(int, str.split()))

print(lst)






'''
run:

[5, 8, 2, 1, 0, 6]

'''

 



answered Feb 19, 2022 by avibootz

Related questions

1 answer 136 views
1 answer 187 views
2 answers 199 views
2 answers 215 views
2 answers 246 views
1 answer 153 views
...