cut off part of string python code example

Example 1: get a slice of string in python

string = "something"

slice = string[0:3] # will be "som"
slice = string[0:-3] # will be "someth"
slice = string[3:] # will be "thing"
slice = string[:3] # same as first slice
slice = string[::2] # will be "smtig" -- it goes 2 step each time

Example 2: remove part of string python

txt = 'abbacabbd'
print(url.replace('bbd',''))

#output:
abbaca

Example 3: remove a part of a string python

url = 'abcdc.com'
print(url.replace('.com',''))