How to Print all Elements Except First in Python?

23-Nov-2022

.

Admin

How to Print all Elements Except First in Python?

Hi Dev,

This article will provide some of the most important example how to print all elements except first in python. This tutorial will give you simple example of python print all elements in list except first. This post will give you simple example of python all elements except first. I’m going to show you about python all items in list except first.

There are many ways to get all elements except the first element in list python. i will give you two examples using for loop with list[1:] to except first element from list. so let's see the below examples.

so let's see following examples with output:

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

#Python