Online Python Compiler

def solve(s,t): n = len(s) m = len(t) dp= [[False for i in range(m+1)] for i in range(n+1)] dp[0][0] = True for i in range(len(s)): for j in range(len(t)+1): if dp[i][j] == True: if j < len(t) and (s[i].upper() == t[j]): dp[i + 1][j + 1] = True if s[i].isupper()==False: dp[i + 1][j] = True return dp[n][m] s = "fanToM" t = "TOM" print(solve(s, t))