Write a function definition of occurrences(text1, text2) that takes two string arguments. The function returns the number of times a character from the first argument occurs in the second argument. code example
Example: Write a function definition of occurrences(text1, text2) that takes two string arguments. The function returns the number of times a character from the first argument occurs in the second argument.
def occurrences(text1, text2):
"""Return the number of times characters from text1 occur in text2
occurrences(string, string) -> int
"""
text1_dict = {char:0 for char in text1}
for char in text2:
if char in text1_dict:
text1_dict[char] += 1
return sum(list(text1_dict.values()))