String indexing and slicing


Indexing and slicing are powerful tools in Python that allow you to access specific elements or parts of a sequence. Both indexing and slicing use square brackets. Remember that in a slice the starting index is inclusive and the stopping index is exclusive, and that negative indices count from the end of the sequence

my_string = 'Mississippi half-step'
print(my_string[0])
print(my_string[0:3])
print(my_string[6:])

my_list = [1, 'unladen', 'swallow']
print(my_list[1])
print(my_list[-1])

url = 'https://exampleURL1.com/r626c36'

def url_checker(url):
    url = url.split('/')
    print(url)

url_checker(url)
['https:', '', 'exampleURL1.com', 'r626c36']