Python Access Index of List Items Using For Loop

preview_player
Показать описание
In this Python tutorial, we will go over how to access the index of list items.
Рекомендации по теме
Комментарии
Автор

Below is another example:
list1 = ['a', 'b', 'c', 'd', 'e']
for i in range(0, len(list1)):
print(i, list1[i])

RyanNoonan
Автор

And how am I want to print each element of the list starting by the last one?

dahk
Автор

I am so lost on how to increment the indexes in python. For example if i have a list
list1 = [1, 2, 3, 4, 5, 6]
I want to be able to print out things like
[1, 6] or [2, 5] or [3, 4] etc.. what kind of for loop do i use so that i can increment the indexes?

thatssokj
Автор

who can help me in this, I want it to return -1 if the item is not in the list using the for loop. I tried a lot but it is not working

Danah_eqh
Автор

how do you access multiple items in a list?

carlarached