access the elements of a list in Python

 Question:-

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 :-

  1. lis=[1,2,3,4,5,6,7,89] 
  2. print(li[0]) # for positive indexing 
  3. 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

Popular posts from this blog

Proassignmenthelp index 27

check whether the given input is alphabet, number or alphanumeric in python