Suppose we have two strings s and t. We have to check whether s is suffix of t or not.
So, if the input is like s = "ate" t = "unfortunate", then the output will be True.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(s, t): s_len = len(s) t_len = len(t) if (s_len > t_len): return False for i in range(s_len): if(s[s_len - i - 1] != t[t_len - i - 1]): return False return True s = "ate" t = "unfortunate" print(solve(s, t))