mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-30 06:31:46 -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:
@@ -9,15 +9,6 @@ Ported by Dave LeCompte
|
||||
import random
|
||||
|
||||
|
||||
def print_with_tab(num_spaces: int, msg: str) -> None:
|
||||
if num_spaces > 0:
|
||||
spaces = " " * num_spaces
|
||||
else:
|
||||
spaces = ""
|
||||
|
||||
print(spaces + msg)
|
||||
|
||||
|
||||
def print_instructions() -> None:
|
||||
print("YOU HAVE 100 POINTS. BY GUESSING NUMBERS FROM 1 TO 5, YOU")
|
||||
print("CAN GAIN OR LOSE POINTS DEPENDING UPON HOW CLOSE YOU GET TO")
|
||||
@@ -33,11 +24,8 @@ def fnr():
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print_with_tab(33, "NUMBER")
|
||||
print_with_tab(15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
print()
|
||||
print()
|
||||
print()
|
||||
print(" " * 33 + "NUMBER")
|
||||
print(" " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
|
||||
print_instructions()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user