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 145 views
1 answer 193 views
2 answers 206 views
2 answers 228 views
2 answers 259 views
1 answer 161 views
...