Python Get First Element of List Example
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:
myList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # Get First Element firstElem = myList print(firstElem)Output
myList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # Get First Element firstElem = myList[:1] print(firstElem)Output
It will help you....
Happy Pythonic Coding!