Simplify Python Code

print_with_tab / print_with_whitespace is trivial with Python
string formatting and was mostly used in only 2 lines.
This commit is contained in:
Martin Thoma
2022-04-02 07:32:09 +02:00
parent 354c1f9ab3
commit c500424956
47 changed files with 208 additions and 387 deletions

View File

@@ -1,7 +1,9 @@
# Original BASIC version as published in Basic Computer Games (1978)
# https://www.atariarchives.org/basicgames/showpage.php?page=55
#
# Converted to Python by Anson VanDoren in 2021
"""
Original BASIC version as published in Basic Computer Games (1978)
https://www.atariarchives.org/basicgames/showpage.php?page=55
Converted to Python by Anson VanDoren in 2021
"""
import math
import random
@@ -38,7 +40,7 @@ def get_num_charges() -> Tuple[int, int]:
def ask_for_new_game() -> None:
answer = input("Another game (Y or N): ")
if answer.lower().strip()[0] == "y":
start_new_game()
main()
else:
print("OK. Hope you enjoyed yourself")
exit()
@@ -112,10 +114,10 @@ def play_game(search_area, num_charges):
ask_for_new_game()
def start_new_game() -> None:
def main() -> None:
search_area, num_charges = get_num_charges()
play_game(search_area, num_charges)
if __name__ == "__main__":
start_new_game()
main()