Python Tutorials

TypeError: strip arg must be none or str


rstrip and lstrip methods behave similarly.

Example:

str = '123456'
new_str = str.strip(12) # we have passed int

Output:

>>>TypeError: strip arg must be None or str


If we pass '12'(string) instead of 12 (int)

str = '123456'
new_str = str.strip('12') # we have passed string

Output:

>>>'3456'


For more information about strip functions:strip() method, rstrip() method and lstrip() method