How to remove spaces at the beginning and at the end of the string

use the strip() to remove trailing and leading spaces.

def method_strip(s: str):
    return s.strip()

you can also use this method to remove different kind of characters leading/trailing characters for example:

s = "0000..brohelp..00"
s = s.strip(".0")
print(s)

output

brohelp