Skip to content

Instantly share code, notes, and snippets.

@acbart
Created August 12, 2022 17:27
Show Gist options
  • Save acbart/acb2a2bdbc5f7f47434442083bff0c48 to your computer and use it in GitHub Desktop.
Save acbart/acb2a2bdbc5f7f47434442083bff0c48 to your computer and use it in GitHub Desktop.
Middle Function Example
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