xxxxxxxxxx
# Example usage of the strip function
string = " Hello, World! "
stripped_string = string.strip()
print(stripped_string)
xxxxxxxxxx
# removes outside whitespace/characters
' hey '.strip() # "hey"
' hey '.lstrip() # "hey "
' hey '.rstrip() # " hey"
'_.hey__'.strip('._') # "hey"
xxxxxxxxxx
txt = " test "
txt.strip()
#Output: "test"
txt.lstrip()
#Output: "test "
txt.rstrip()
#Output: " test"
xxxxxxxxxx
txt = ",,,,,rrttgg.....banana....rrr"
x = txt.strip(",.grt")
#outputs banana
print(x)
xxxxxxxxxx
'''
to use the split function, will have to ask the user for their email address, and we will
try to split the "@"
x = input("Email should contain @: ")
romeo = x.split('@')
print(romeo)
xxxxxxxxxx
# Мөрний эхэн ба төгсгөлийн тэмдэгтүүдийг арилгахын тулд .strip() аргыг ашиглаж болно.
# Мөрийн аргументыг арга руу дамжуулж, арилгах тэмдэгтүүдийн багцыг зааж өгч болно.
# Аргын аргумент байхгүй бол хоосон зай арилна.
text1 = ' apples and oranges '
text1.strip() # => 'apples and oranges'
text2 = '...+...lemons and limes...-...'
# Here we strip just the "." characters
text2.strip('.') # => '+...lemons and limes...-'
# Here we strip both "." and "+" characters
text2.strip('.+') # => 'lemons and limes...-'
# Here we strip ".", "+", and "-" characters
text2.strip('.+-') # => 'lemons and limes'
xxxxxxxxxx
string = " Hello, World! "
stripped_string = string.strip()
print(stripped_string) # Output: "Hello, World!"
xxxxxxxxxx
lol = ' lol '
print(lol)
# normal output = lol
lol = ' lol '
print(lol.strip)
# strip output = lol
# Cool right