+ 2

# Can any one explain indexing in python ?

24th Sep 2022, 6:41 AM
Sohan Singh
+ 8
index: 0, 1, 2, 3 value=[10, 23, 3, 5] index: -4, -3, -2, -1
24th Sep 2022, 8:49 AM
Solo
+ 2
can you give an example of what you don't understand
24th Sep 2022, 7:24 AM
dan
+ 2
Sohan Singh , > we can use the list index() method to check for the index number of an element from the list. > we can also get all of the indexes of the elements of the list by iterating over the list. use a counter that will be updated in each loop iteration.
24th Sep 2022, 11:57 AM
Lothar
+ 2
Sohan Singh Hii mate !! May this help you and good luck. #How to access elements in string ? """Two ways: 1. indexing 2. slicing index : index is used to access single element in the string slicing : slicing is used to access group of elements in the string """ #name = "index value" # 012345678910 #can also use negative value to access element backward. #syntax: print(var_name[index]) name = "karan singh" print(name[4]) print(name[-7] ) #slicing """slicing : slicing is used to access group of elements in string """ name = "karan singh" print(name[0:4]) print(name[:-4:-1]) print(name[0:0]) print(name[-1:-5:-3]) Run_this ="udohyheuvkomlri" print(Run_this[::-2]) #Done
24th Sep 2022, 6:22 PM
KARAN SINGH D
+ 2
Sohan Singh , you have done the *python core* tutorial and also some other python tutorials, so i am sure that you are able to solve this problem by yourself.
24th Sep 2022, 6:34 PM
Lothar
+ 2
indexing is simply a way of allocating identifiers especially numbers to elements in an array. For example: In the code bellow, we have an array(list) that stores the value of numbers from 1 to 10. If we want to use the elements in it, we have to index it, that is like giving it a position. Starting from the left, to the rights, all the elements in the list start from 0 upward... #list list_of_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] #Indexing will be 0, 1, 2.. #where 1 in the list marches to the index 0 Also, note: to find the index of an element, we can also use the index() function in python...
24th Sep 2022, 8:47 PM
Ohene
+ 2
You can use the index method to get an index number for the first occurrence For a list a=[1,23,3,5], a.index(3) would return 2.
25th Sep 2022, 2:20 PM
Josh Wozny
+ 1
Like how to cheak which element which position ex like [1,23,3,5] this
24th Sep 2022, 7:51 AM
Sohan Singh
+ 1
It is the position of a data type
25th Sep 2022, 10:10 AM