1
l1 = [2345]

I want the following output

[2, 3, 4, 5]
Ch3steR
  • 20,090
  • 4
  • 28
  • 58

4 Answers4

1

use this block of code:

l1 = [2345]
l1_str = str(l1[0])
l1_sep = []
for i in l1_str:
    l1_sep.append(int(i))
print(l1_sep)

or something like this:

list(map(int, str(l1[0])))
0

If you always have a single-element list then you could do this:

li1 = [1234]
li_output = [int(elem) for elem in str(li1[0])]

print(li_output)

>>> [1, 2, 3, 4]
0

or you can use a construct like this

l1 = [2345]
l2 = [int(number) for number in str(l1[0]) ]
print(l2)
Key27
  • 9
  • 2
0
l1 = [1234]
a = list(str(l1[0]))
a = [1,2,3,4] output.
Susan
  • 238
  • 3
  • 11