why negative indexing is used in python code example

Example 1: python negative indexing

list = ["Python", "Java", "C++", "Javascript", "SQL", "PHP"]
print(list[-1]) # "PHP"
print(list[-4]) # "C++"
print(list[:-3]) # ["Python", "Java", "C++"]
print(list[-2:]) # ["Javascript", "SQL", "PHP"]
print(list[-5:-2]) # ["Java", "C++", "Javascript"]

Example 2: negative indexing in python

thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[-2:])

# ["melon","mango"]