Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created August 31, 2018 14:14
Show Gist options
  • Save mauricioaniche/91b092748455c71a8432d93dd71e3f3f to your computer and use it in GitHub Desktop.
Save mauricioaniche/91b092748455c71a8432d93dd71e3f3f to your computer and use it in GitHub Desktop.
def count(message):
words = 0
last = ' '
for letter in message:
if not letter.isalpha() and (last == 'r' or last == 's'):
words = words + 1
last = letter
if last == 'x' or last == 's':
words = words + 1
return words
def test_multiple_matching_words() :
assert count("cats|dogs") == 2
def test_last_doesnt_match() :
assert count("cats|dog") == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment