Access List Item by Index :
thislist = ["apple", "banana", "cherry"]
print(thislist[1])
Output :
banana
Access Last Item Using Negative Index :
thislist = ["apple", "banana", "cherry"]
print(thislist[-1])
Output :
cherry
Access List Slice (2:5) :
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[2:5])
Output :
['cherry', 'orange', 'kiwi']
Slice from Start to Index 3 :
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[:4])
Output :
['apple', 'banana', 'cherry', 'orange']
Slice from Index 2 to End :
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[2:])
Output :
['cherry', 'orange', 'kiwi', 'melon', 'mango']
Slice with Negative Indexes :
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist[-4:-1])
Output :
['orange', 'kiwi', 'melon']