mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-21 23:00:43 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -14,6 +14,7 @@ import random
|
||||
|
||||
BELLS_ON_SUCCESS = False
|
||||
|
||||
|
||||
def print_with_tab(space_count, msg):
|
||||
if space_count > 0:
|
||||
spaces = " " * space_count
|
||||
@@ -22,6 +23,7 @@ def print_with_tab(space_count, msg):
|
||||
|
||||
print(spaces + msg)
|
||||
|
||||
|
||||
def print_instructions():
|
||||
print("LETTER GUESSING GAME")
|
||||
print()
|
||||
@@ -29,38 +31,40 @@ def print_instructions():
|
||||
print("TRY TO GUESS MY LETTER AND I'LL GIVE YOU CLUES")
|
||||
print("AS TO HOW CLOSE YOU'RE GETTING TO MY LETTER.")
|
||||
|
||||
|
||||
def play_game():
|
||||
target_value = random.randint(ord('A'), ord('Z'))
|
||||
target_value = random.randint(ord("A"), ord("Z"))
|
||||
num_guesses = 0
|
||||
print()
|
||||
print("O.K., I HAVE A LETTER. START GUESSING.")
|
||||
print()
|
||||
while True:
|
||||
print("WHAT IS YOUR GUESS?")
|
||||
num_guesses += 1
|
||||
guess = ord(input())
|
||||
print()
|
||||
if guess == target_value:
|
||||
print()
|
||||
print(f"YOU GOT IT IN {num_guesses} GUESSES!!")
|
||||
if num_guesses > 5:
|
||||
print("BUT IT SHOULDN'T TAKE MORE THAN 5 GUESSES!")
|
||||
# goto 515
|
||||
print("GOOD JOB !!!!!")
|
||||
|
||||
if BELLS_ON_SUCCESS:
|
||||
bellStr = chr(7) * 15
|
||||
print(bellStr)
|
||||
|
||||
print()
|
||||
print("LET'S PLAY AGAIN.....")
|
||||
return
|
||||
elif guess > target_value:
|
||||
print("TOO HIGH. TRY A LOWER LETTER.")
|
||||
continue
|
||||
else:
|
||||
print("TOO LOW. TRY A HIGHER LETTER.")
|
||||
continue
|
||||
print("WHAT IS YOUR GUESS?")
|
||||
num_guesses += 1
|
||||
guess = ord(input())
|
||||
print()
|
||||
if guess == target_value:
|
||||
print()
|
||||
print(f"YOU GOT IT IN {num_guesses} GUESSES!!")
|
||||
if num_guesses > 5:
|
||||
print("BUT IT SHOULDN'T TAKE MORE THAN 5 GUESSES!")
|
||||
# goto 515
|
||||
print("GOOD JOB !!!!!")
|
||||
|
||||
if BELLS_ON_SUCCESS:
|
||||
bellStr = chr(7) * 15
|
||||
print(bellStr)
|
||||
|
||||
print()
|
||||
print("LET'S PLAY AGAIN.....")
|
||||
return
|
||||
elif guess > target_value:
|
||||
print("TOO HIGH. TRY A LOWER LETTER.")
|
||||
continue
|
||||
else:
|
||||
print("TOO LOW. TRY A HIGHER LETTER.")
|
||||
continue
|
||||
|
||||
|
||||
def main():
|
||||
print_with_tab(33, "LETTER")
|
||||
@@ -74,5 +78,6 @@ def main():
|
||||
while True:
|
||||
play_game()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user