Created
June 20, 2022 10:21
-
-
Save Riggs333/945ad8b895843e613fbe6788ea7b8917 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 generate_guess(candidate: str, count: int): | |
num = "" | |
v = "" | |
modifier = "" | |
if count == 0: | |
num = "no" | |
v = "are" | |
modifier = "s" | |
elif count == 1: | |
num = "1" | |
v = "is" | |
modifier = "" | |
else: | |
num = str(count) | |
v = "are" | |
modifier = "s" | |
guess_message = "There {0} {1} {2}{3}".format(v, num, candidate, modifier) | |
return guess_message | |
def test_zero(): | |
assert generate_guess("FOO", 0) == "There are no FOOs" | |
def test_one(): | |
assert generate_guess("BAR", 1) == "There is 1 BAR" | |
def test_many(): | |
assert generate_guess("BAZ", 42) == "There are 42 BAZs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment