Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8
index: 0, 1, 2, 3 value=[10, 23, 3, 5] index: -4, -3, -2, -1
24th Sep 2022, 8:49 AM
Solo
Solo - avatar
+ 2
can you give an example of what you don't understand
24th Sep 2022, 7:24 AM
dan
dan - avatar
+ 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
Lothar - avatar
+ 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
KARAN SINGH D - avatar
+ 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
Lothar - avatar
+ 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
Ohene - avatar
+ 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
Josh Wozny - avatar
+ 1
It is the position of a data type
25th Sep 2022, 10:10 AM
Adrian Mróz
Adrian Mróz - avatar
+ 1
Imagine that the index is your toy car collection, from 1 to 10 cars. Each car has a number from 1-10.You forgot where did you put the first toycar you ever bought. lets take a look at this command for example: Car = [1,2,3,4,5,6,7,8,9,10] #This is the list of every car you bought, starting from 1 to the right is the first-last car you ever bought from ur collection(list), from lowest to largest.You wanna know what is the first car u ever bought in your collection so, you need to print it using index. print(Car.index(1)) #This will tell you the position of the first car you ever bought in your collection However, when printing the first number on the index, it always start at 0 unless you wanna print the another number after the first number on the list. the program in the example prints 0 to the screen, that is the position of the car. another code for sample: list = [5,7,9,11] print(list.index(9)) #Output 2
25th Sep 2022, 2:39 PM
Dragon RB
Dragon RB - avatar
0
index starts from 0 to n
25th Sep 2022, 11:53 PM
JASON