access the elements of a list in Python
How do you access the elements of a list in Python?
access the elements of a list in Python:-
accessing the elements in list is very easy we can access by just their index in list. by indexing it can be access by two different ways first is positive index and second is negative indexing.
in positive indexing it will be start from 0 and beginning but in negative it will be start from -1 and from the end of list.
it can be understand more by an example. Let’s see an example of it.
Example :-
- lis=[1,2,3,4,5,6,7,89]
- print(li[0]) # for positive indexing
- print(li[-1]) # for negative indexing
For more basic Question of Python and Question of Hackerrank with solution please visit my blog.
Thank You
Comments
Post a Comment