mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-24 20:10:15 -08:00
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:
@@ -134,17 +134,10 @@ SAFE_SPOTS: Final[FrozenSet[Tuple[int, int]]] = COMPUTER_SAFE_SPOTS | frozenset(
|
||||
)
|
||||
|
||||
|
||||
def str_with_tab(indent: int, text: str, uppercase: bool = True) -> str:
|
||||
"""Create a string with ``indent`` spaces followed by ``text``."""
|
||||
if uppercase:
|
||||
text = text.upper()
|
||||
return " " * indent + text
|
||||
|
||||
|
||||
def intro() -> None:
|
||||
"""Print the intro and print instructions if desired."""
|
||||
print(str_with_tab(33, "Queen"))
|
||||
print(str_with_tab(15, "Creative Computing Morristown, New Jersey"))
|
||||
print(" " * 33 + "Queen")
|
||||
print(" " * 15 + "Creative Computing Morristown, New Jersey")
|
||||
print("\n" * 2)
|
||||
if ask("DO YOU WANT INSTRUCTIONS"):
|
||||
print(INSTR_TXT)
|
||||
|
||||
Reference in New Issue
Block a user