How to Print All Elements Except First in List Python?

Published On: 30/11/2022 | Category: Django


Hi Guys,

Today, python list get all elements except first is our main topic. you will learn python list get all but not first element. This post will give you simple example of how to print all elements except first in list python. you'll learn python all items in list except first.

In list python, there are several ways to get all elements except the first one. I'll show you two examples of how to use a for loop with list[1:] to exclude the first element from a list. So, take a look at the examples below.

So let's see bellow example:

Example 1:

main.py
myList = [1, 2, 3, 4, 5]
  
# Get All Value Except First One
myList = myList[1:]
  
print(myList)
Output
[2, 3, 4, 5]

Example 2:

main.py
myList = ["One", "Two", "Three", "Four", "Five"]
  
# Get All Value Except First One
for listElem in myList[1:]:
  print(listElem)
Output
Two
Three
Four
Five

It will help you....

Happy Pythonic Coding!