Python Get First Element of List Example
Published On: 07/11/2022 | Category:
Python

Hi Guys,
This tutorial will provide example of python get first element of list of lists. step by step explain python get first element from list. if you have question about how to get first element of list in python then I will give simple example with solution. you can see how to get first n elements of a list in python. So, let's follow few step to create example of python first element of list.
In Python, there are various methods for obtaining the first entry from a list. Either return a single value in a string or return an array starting with the first value could be used. Let's look at the following examples:
So let's see bellow example:
Example 1
main.pymyList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # Get First Element firstElem = myList[0] print(firstElem)Output
Sun
Example 2
main.pymyList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # Get First Element firstElem = myList[:1] print(firstElem)Output
['Sun']
It will help you....
Happy Pythonic Coding!