sentence slice in django code example
Example 1: slicing in python
word = "Example"
# Obtain the first 3 characters of "Example"
# E x a m p l e
# 0 1 2 3 4 5 6
# First 3 characters = "Exa"
sliced_word = word[:3] # Gives you "Exa"
# Everything after character #3 = "mple"
second_sliced_word = word[3:] # Gives you "mple"
Example 2: is : and :: the same in python slice
a[-1] # last item in the array
a[-2:] # last two items in the array
a[:-2] # everything except the last two items