Removing duplicates function

python

#1

https://www.codecademy.com/courses/learn-python/lessons/practice-makes-perfect/exercises/removeduplicates?action=resume_content_item

part of the solution of this code involves this:

if i > outputlist[-1]:
outputlist.append(i)

what on earth is outputlist[-1]? isnt the value inside the square brackets supposed to be the index? isnt the smallest possible index value 0 i.e. the very first item in a list?


#2

python allows to use negative indexes to access values from the right hand side of the list, so -1 is the last item, -2 is the second to last item in the list, and so on