-5

Cut down the same list into given index

Let's say we have a list

mainList = [3,5,2,7,0,9]

If I remove 3 item then mainList should be

[7,0,9]

Is there a way to do that?

Airn5475
  • 2,452
  • 29
  • 51
Sunil Kumar
  • 61
  • 1
  • 12

1 Answers1

0

If you want to delete the first n occurences in a list:

mainList = [3,5,2,7,0,9]
for i in range(0,3):
    mainList.pop(0)
print(mainList)

Output:

[7, 0, 9]
Celius Stingher
  • 17,835
  • 6
  • 23
  • 53