Let's say I want to create a list. The list need to have a MAX length of 5. The list would operate as such:
list = []
list.append(1)
list = [1]
list.append(2)
list = [1,2]
..
list.append(5)
list = [1,2,3,4,5]
But, when I append another number the first element is removed:
list.append(6)
list = [2,3,4,5,6]
This is super basic and I can't figure this one out.
I don't want to use classes - can this be done with basic functions such as slices?