+ 1
Help in python
How to index a element
5 odpowiedzi
+ 7
Hii, index in python starts from 0 and is used to access an element from a list, try Sololearn lesson name "Indexing" for deep information.
+ 5
Pa Thé ,
it would be better to share a code with us so that we can see (without guessing) what your issue is.
in general:
an index has to be an integer number or a variable that holds an integer number. by increasing or decreasing with a value we can modify the index number.
in python indexes can be positive or negative, and does not necessarily need to start with the value of zero. indexes can be used with all sequences / iterables, so they are not limited to lists only.
in python we can create an index number by using a for loop combined with an enumerator like:
lst = [4,8,0,2,1]
for ndx, num in enumerate(lst):
...
> num is a variable that will get a value from the list, one at a time
> ndx is a variable that will get an int value for indexing, that is incremented automatically in each loop iteration.
you can find more about the enumerate() function in the python docs.
+ 1
Do python course carefully and you'll be a pro on indexing.
+ 1
Chill bro 🥲
0
If you wanna help okay else shut up