I tried to remove and element from t, based on whether it is present in s, this is the code I wrote, however 'd' is not being removed. So my question is. Why is 'd' not being removed from t when it certainly is not in s?
def isSubsequence(s: str, t: str) -> bool:
s = list(s)
t = list(t)
for i in t:
if i not in s:
t.remove(i)
print(t)
isSubsequence('abc', 'ahbgdc')
Output:
['a', 'b', 'd', 'c']