How to convert a number into a list of integers in Python

2 Answers

0 votes
num = 93285
  
lst = [int(d) for d in str(num)] 

print(lst)



'''
run:
 
[9, 3, 2, 8, 5]

'''

 



answered Feb 13, 2020 by avibootz
0 votes
num = 93285
  
lst = list(map(int, str(num))) 

print(lst)



'''
run:
 
[9, 3, 2, 8, 5]

'''

 



answered Feb 13, 2020 by avibootz

Related questions

...