﻿ Python: Remove and print every third number from a list of numbers until the list becomes empty - w3resource

# Python: Remove and print every third number from a list of numbers until the list becomes empty

## Python Basic - 1: Exercise-3 with Solution

Write a Python program to remove and print every third number from a list of numbers until the list becomes empty.

Pictorial Presentation: Sample Solution:

Python Code :

``````def remove_nums(int_list):
#list starts with 0 index
position = 3 - 1
idx = 0
len_list = (len(int_list))
while len_list>0:
idx = (position+idx)%len_list
print(int_list.pop(idx))
len_list -= 1
nums = [10,20,30,40,50,60,70,80,90]
remove_nums(nums)
``````

Sample Output:

```30
60
90
40
80
50
20
70
10
```

Flowchart: ## Visualize Python code execution:

The following tool visualize what the computer is doing step-by-step as it executes the said program:

Python Code Editor :

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

﻿

Inviting useful, relevant, well-written and unique guest posts