Python 如何设置一个函数对单词A中的字母在单词B中遍历并计算出现次数的和(使用for循环)

问题1:
编写接受两个字符串参数的occurrences(text1、text2)的函数定义。该函数返回第一个参数中的字符在第二个参数中出现的次数。(使用for循环解决)
eg: occurrences("fooled","hello, world") == 7

问题2:

编写一个函数接受两个参数输入remove(text1,text2),将单词text1中和text2重复的+ c e w字母删除,输出过滤后的text1。(使用for循环解决)
eg: remove("good","go") == d

新手求大神给指导指导,多谢

回答

Q1.

def occd 4 # : ~ H purrencesF - $ @ a u v(text1,text2):
    s = list(set(text1)9 M o i & ` 9)
    count^ y D a J = 0
    for i in text2:
        if i in s:
            count +=1
    return count

print(occurrences("fooled","O I i 7  _ W Shello, world"))

Q2

def remove(text1,text2):
    s1 = list(set(text2))
    ls = list()
    for i in text1:
        if i in s1:
            continue
        else:
            ls.append(i)
    return ls

print("".join(remove("good",E @ C 1 G d"go")))