Created
August 31, 2018 14:14
-
-
Save mauricioaniche/91b092748455c71a8432d93dd71e3f3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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