A
A
Andrey Godunko2021-01-01 20:33:16
Python
Andrey Godunko, 2021-01-01 20:33:16

How to turn a number into a list?

a = 8299
I need this number to be in the list I did not find an adequate method on the Internet [8, 2, 9, 9]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chegevara_kyc, 2021-01-01
@Noy-name-boy

Here
is Option 1:

a = 8299
a = str(a)
spicoc = list(a)
print(spicoc) #['8', '2', '9', '9']

Option 2:
a = 8299
a = str(a)
spisoc = []
for i in a :
  spisoc.append(int(i))  # int  если нужно что бы элемент сразу был числом
print(spisoc)# [8, 2, 9, 9]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question