Program to insert a number into an empty list

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

for char in data:
    if char.isnumeric():
        List.append(int(char))
        
print(List)
				
			

Output :

				
					[1, 2, 5]
				
			

count the total numbers of odd numbers between 1-100

get input from the user if it is a string insert it into an empty list

Leave a Comment