mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -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:
@@ -7,14 +7,6 @@ Ported by Dave LeCompte
|
||||
"""
|
||||
|
||||
|
||||
def print_with_tab(space_count: int, msg: str) -> None:
|
||||
if space_count > 0:
|
||||
spaces = " " * space_count
|
||||
else:
|
||||
spaces = ""
|
||||
print(spaces + msg)
|
||||
|
||||
|
||||
def print_diamond(begin_width, end_width, step, width, count) -> None:
|
||||
edgeString = "CC"
|
||||
fill = "!"
|
||||
@@ -38,11 +30,8 @@ def print_diamond(begin_width, end_width, step, width, count) -> None:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print_with_tab(33, "DIAMOND")
|
||||
print_with_tab(15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
print()
|
||||
print()
|
||||
print()
|
||||
print(" " * 33, "DIAMOND")
|
||||
print(" " * 15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n\n\n")
|
||||
print("FOR A PRETTY DIAMOND PATTERN,")
|
||||
print("TYPE IN AN ODD NUMBER BETWEEN 5 AND 21")
|
||||
width = int(input())
|
||||
|
||||
Reference in New Issue
Block a user