§ 2.4.1section 7 of 18·~4 min
Lists and tuples
amounts = [499, 1299, 250]
amounts.append(799)
print(amounts[0]) # first item
print(amounts[-1]) # last item
print(amounts[1:3]) # a slice
print(len(amounts), sum(amounts))
location = (12.97, 77.59) # a tuple: lat, lon
OUTPUT
499
799
[1299, 250]
4 2847Indexes start at 0. Negative indexes count back from the end. A slice [a:b] includes position a and stops just before b.
A tuple works like a list you can't change. Use one when values belong together and shouldn't be edited, like a coordinate pair.