I want to write a function which prints the items in a list that all contain at least one similar character and the amount of times it appears in each item. For example if I had the following list:
ex = ['bat', 'cat', 'task', 'tank', 'tan']
Each item contains the letter 'a' and 't' at least once.
I know I could use
for string in ex:
for letter in string:
x = string.count("a")
print(string, "has", x, "a")
for string in ex:
for letter in string:
x = string.count("t")
print(word, "has", x, "t")
How would I do this without specifying the actual characters to search for like above, in case I would like to change the list?