mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -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:
@@ -24,7 +24,6 @@ cards = {
|
||||
|
||||
|
||||
def play_game() -> None:
|
||||
"""Play the game"""
|
||||
cash = 100
|
||||
while cash > 0:
|
||||
print(f"You now have {cash} dollars\n")
|
||||
@@ -64,16 +63,6 @@ def play_game() -> None:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Main"""
|
||||
keep_playing = True
|
||||
|
||||
while keep_playing:
|
||||
play_game()
|
||||
keep_playing = input("Try again? (yes or no) ").lower().startswith("y")
|
||||
print("Ok hope you had fun")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(
|
||||
"""
|
||||
Acey-Ducey is played in the following manner
|
||||
@@ -84,4 +73,13 @@ a value between the first two.
|
||||
If you do not want to bet, input a 0
|
||||
"""
|
||||
)
|
||||
keep_playing = True
|
||||
|
||||
while keep_playing:
|
||||
play_game()
|
||||
keep_playing = input("Try again? (yes or no) ").lower().startswith("y")
|
||||
print("Ok hope you had fun")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user