Junior — Senior
Overloading the subtraction operator for a custom string class
livecode
Task condition
It is necessary to implement a custom String class that supports subtracting one string from another using the - operator. If the first string starts with the substring passed in the second object, that substring should be removed from it; otherwise, the original string is returned. To implement this, override the corresponding magic method.
def dif_str(a: str, b: str) -> str:
if a.startswith(b):
return a.replace(b, '', 1)
return a