str1 = "abc" str2 = "abcdef" res = [] for x in str1: if x in str2: res.append(x) print(res)
若有帮助,请采纳!