Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Two Stupid Method Solve It solution in Clear category for Monkey Typing by JingweiWu
def count_words(text, words):
count = 0
for var in words:
#First Method
#for i in range(0,len(text) - 1):
#if i > len(text) - len(var):
#break
#if var.lower() == text[i:i+len(var)].lower():
#count += 1
#break
#Second Method
if var.lower() in text.lower():
count += 1
return count
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert count_words("How aresjfhdskfhskd you?", {"how", "are", "you", "hello"}) == 3, "Example"
assert count_words("Bananas, give me bananas!!!", {"banana", "bananas"}) == 2, "BANANAS!"
assert count_words("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
{"sum", "hamlet", "infinity", "anything"}) == 1, "Weird text"
May 11, 2016