Phira
0
Q:

how to index lists in python

list.index(element)
13
#Example List
list = ['apples', 'bannas', 'grapes']
#Use Known Entites In The List To Find The Index Of An Unknown Object
Index_Number_For_Bannas = list.index('apples')
#Print The Object
print(list[Index_Number_For_Bannas])
9
# Make the list
list = ['bananas', 'apples', 'watermellon']
# Print the word apples from the list
print(list[1])
2
# vowels list
vowels = ['a', 'e', 'i', 'o', 'i', 'u']

# index of 'e' in vowels
index = vowels.index('e')
print('The index of e:', index)

# element 'i' is searched
# index of the first 'i' is returned
index = vowels.index('i')

print('The index of i:', index)
0
#you can index in a string like:
string='cupcake'
string[0]#returns 'c'
#you can index in a list like:
list = ['red', 'blue', 'green']
list[0]#returns 'red'
list[0][0]#returns[0] of 'red' wich is r
0
>>> list1 = [[10,13,17],[3,5,1],[13,11,12]]
>>> list1[0][2]
17
0

New to Communities?

Join the community