Created
August 12, 2022 17:27
-
-
Save acbart/acb2a2bdbc5f7f47434442083bff0c48 to your computer and use it in GitHub Desktop.
Middle Function Example
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
from bakery import assert_equal | |
def middle(text: str, length: int) -> str: | |
""" Determine the middle character of a string """ | |
index = length // 2 | |
letter = text[index] | |
return letter | |
assert_equal(middle("Hello", 5), "l") | |
assert_equal(middle("Frog", 4), "o") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment