0

i wanted to make a code which you put a random number using Input (Should be more than two dights) and the program make it a list which is every dight alone, or with more precise I wont to spell the numbers

i've tried this and i don't found any solution

Ex of what i want to do:

input = "57472"
output = [5, 7, 4, 7, 2]

2 Answers2

0

A simple [int(x) for x in input] would do, if I understand the question correctly.

For list comprehension, look at eg: https://www.programiz.com/python-programming/list-comprehension

0

Try: m_list = input.split('')

It will split the string into it's chars, if you want the elements to be int just convert each of them

Yossi Levi
  • 1,258
  • 1
  • 4
  • 7