Integers to list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Integers to list

how can an integer be split into a list e. g n=123 so I want n to be split into list that looks like this [1,2,3]

1st Oct 2018, 5:49 PM
‏‪‏‪Sammy_Jamez‬‏‬‏
‏‪‏‪Sammy_Jamez‬‏‬‏ - avatar
1 Answer
+ 9
n = 123 nList = list(map(lambda x: int(x), str(n)))
1st Oct 2018, 5:51 PM
Burey
Burey - avatar