Tech Study

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

Introduction

Write a Python program to remove and print every third number from a list of numbers until the list becomes empty. I have used python 3.7 compiler for debugging purpose.

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]
remove_nums(nums)

Result

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

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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more