python remove part of string after character code example
Example 1: remove n from string python
a_string = a_string.rstrip("\n")
Example 2: remove part of string python
txt = 'abbacabbd'
print(url.replace('bbd',''))
#output:
abbaca
Example 3: python extract all characters from string before a character
s1 = "Username: How are you today?"
>>> s1.split(':')
['Username', ' How are you today?']
>>> s1.split(':')[0]
'Username'