Lists Flashcards
Lunghezza lista L
len(L)
return element at an index in list L
L[i]
return last element at an index in list L (2 modi)
L[ len(L) -1]
L[-1]
return the index of a specific value xxx in list L
L.index(xxx)
check if an element xxx is in the list L (boolean)
xxx in L
iterate over a list L (get a list of all the values in all the indexes)
for i in L:
print (i)
access nested element (in index 0, nested in a sublist placed at index 1 of list L)
L [1] [0]
length of sublist placed at index 1 of list L
len( L [1] )
subset list: create a list L2 containing a list with two elements extracted from index 2 of L
L2=L [2 ]
ranges (of subset) to subset in list L2 from list L : starting to end, indefinite starting to end; starting to indefinite end
L2= L [x : y] L2= L [... : y] L2= L [x : ...]
operazioni con elementi della lista L (somma di elementi in index 0 e 1)
xxx=L [0] + L[ 1]