Every element of a list has a position, and positions count from 0: the first is values[0], the second values[1]. A minus counts from the end: values[-1] is the last.
values = [10, 20, 30, 40, 50]values[1:4] # [20, 30, 40]values[:2] # [10, 20]values[3:] # [40, 50]
a:b) gives a part of the list: a included, b not, just like range. An end left empty means "from the start" or "to the end".A slice is not free: it builds a new list and copies every element in it. Take a slice inside a loop and that loop quietly becomes two nested loops.