Python: Type annotations

This commit is contained in:
Martin Thoma
2022-04-02 10:06:15 +02:00
parent c8f86531e9
commit ac184fec42
25 changed files with 241 additions and 245 deletions

View File

@@ -5,7 +5,7 @@ import textwrap
NUMCNT = 9 # How many numbers are we playing with?
def main():
def main() -> None:
print("REVERSE".center(72))
print("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY".center(72))
print()
@@ -14,7 +14,7 @@ def main():
print()
if not input("DO YOU WANT THE RULES? (yes/no) ").lower().startswith("n"):
rules()
print_rules()
while True:
game_loop()
@@ -23,7 +23,7 @@ def main():
return
def game_loop():
def game_loop() -> None:
"""Play the main game."""
# Make a random list from 1 to NUMCNT
numbers = list(range(1, NUMCNT + 1))
@@ -67,12 +67,10 @@ def game_loop():
def print_list(numbers) -> None:
"""Print out the list"""
print(" ".join(map(str, numbers)))
def rules():
"""Print out the rules"""
def print_rules() -> None:
help = textwrap.dedent(
"""
THIS IS THE GAME OF "REVERSE". TO WIN, ALL YOU HAVE