What I am trying to set up is a function that given a certain text will print out the number of times the words ['color', 'Colour', 'Color','Colour']appear. So that I get the following result:
assert colorcount("Color Purple") == 1
assert colorcount("Your colour is better than my colour") == 2
assert colorcount("color Color colour Colour") == 4
What I have is
import re
def colorcount(text):
all_matches = re.findall('color', 'Colour', 'Color'. 'Colour', text)
return len(all_matches)
print(colorcount(text)
It doesn't work so how can I write the code to make it work as I want it to?