In this program, we will take a user input as a list and move all zero digits to the end of a given list of numbers with the help of the below-given steps.
Move all zero digits to the end:
Steps to solve the program
- Take a list as input.
- Create a variable var and assign its value equal to 0.
- Use for loop with the range function to iterate over elements in the list.
- If the iterated element is greater than 0 then assign its value to the temp variable.
- Assign the value of that index number equal to list1[var]
- Now change the value of list1[var] to temp variable.
- Add 1 to the var variable.
- Print the output to see the result i.e. move all zero digits to the end.
Output :
Related Articles
Python program to find the list in a list of lists whose sum of elements is the highest.
Python program to find the items that start with a specific character from a given list.
Python program to count empty dictionaries from the given list.
Python program to remove consecutive duplicates of given lists.
Python program to pack consecutive duplicates of given list elements into sublists.