Steps to solve the program
- Take input through the user.
- Create an empty string.
- Use for loop to iterate over each character from the input.
- Check if the character is a number or not using isnumeric().
- If it is a number then convert it into an integer using int() and add it to the empty list.
- Print the output.
data = "125python"
List = []
for char in data:
if char.isnumeric():
List.append(int(char))
print(List)
Output :
[1, 2, 5]