Python Remove First 2, 3, 4, 5, 10, etc Elements from List Example

By Hardik Savani October 30, 2023 Category : Python

Hi Guys,

In this tutorial, we will go over the demonstration of how to remove first 2 elements from list in python. you can see how to remove first 3 element from list in python. We will look at an example of python list remove first 5 elements. I explained simply about python remove first 10 elements from list.

I will give you 5 examples of how to remove first two, three, four, five, ten elements from list. you can view one by one example that way you can use it what you need. we will use [:numberOfElement] to delete first elements. let's see the examples:

You can use these examples with python3 (Python 3) version.

Example: Python Remove First 2 Elements from List

main.py

# Create New List with Item
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  
n = 2
  
# Python Remove First 2 Elements from List
newList = myList[n:]
  
print(newList)

Output:

[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Example: Python Remove First 3 Elements from List

main.py

# Create New List with Item
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  
n = 3
  
# Python Remove First 3 Elements from List
newList = myList[n:]
  
print(newList)

Output:

[4, 5, 6, 7, 8, 9, 10, 11, 12]

Example: Python Remove First 4 Elements from List

main.py

# Create New List with Item
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  
n = 4
  
# Python Remove First 4 Elements from List
newList = myList[n:]
  
print(newList)

Output:

[5, 6, 7, 8, 9, 10, 11, 12]

Example: Python Remove First 5 Elements from List

main.py

# Create New List with Item
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  
n = 5
  
# Python Remove First 5 Elements from List
newList = myList[n:]
  
print(newList)

Output:

[6, 7, 8, 9, 10, 11, 12]

Example: Python Remove First 10 Elements from List

main.py

# Create New List with Item
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  
n = 10
  
# Python Remove First 10 Elements from List
newList = myList[n:]
  
print(newList)

Output:

[11, 12]

I hope it can help you...

Tags :
Shares