0
How can I get index (1) with values of 4 list [1, 2, 3, 1] on python
5 Réponses
+ 4
You can give a start index, from where you want to look:
thatlist.index(1, 1)
The second argument is the position from where the method reads, so it doesn't get stuck at the first 1.
+ 2
You will get index "1" in this way:
mylist = [1, 2, 3, 1]
print(mylist[1])
This will print: 2, because the '2' is on index 1 in this list.
If you want to get the first element, you have to use Index '0'
+ 2
HonFu , I hope so 😉
But now it's for me also not really clear
+ 1
Ah, that's what was meant? I see...
+ 1
Thanks for your answer all.