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

@@ -231,7 +231,7 @@ def print_board(board) -> None:
print(" ", end="")
for z in range(BOARD_WIDTH):
print(f"{z+1:3}", end="")
print("")
print()
for x in range(len(board)):
print(f"{x+1:2}", end="")
@@ -240,7 +240,7 @@ def print_board(board) -> None:
print(f"{' ':3}", end="")
else:
print(f"{board[x][y]:3}", end="")
print("")
print()
# place_ship
@@ -338,7 +338,7 @@ def initialize_game():
# print out the title 'screen'
print("{:>38}".format("SALVO"))
print("{:>57s}".format("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"))
print("")
print()
print("{:>52s}".format("ORIGINAL BY LAWRENCE SIEGEL, 1973"))
print("{:>56s}".format("PYTHON 3 PORT BY TODD KAISER, MARCH 2021"))
print("\n")