Mar-15-2023, 07:00 PM
(This post was last modified: Mar-15-2023, 07:24 PM by deanhystad.)
Please use python tags when you post your code. I saw you tried. Next time review before hitting the post button.
Since you decided to ignore any advice, what is the purpose of offering more? Break your code into functions as advised, and the error will be obvious.
You are using the wrong variable.
Instead of this:
Since you decided to ignore any advice, what is the purpose of offering more? Break your code into functions as advised, and the error will be obvious.
You are using the wrong variable.
while True: again = input("play again? enter y to play again or n to quit") if again == ("n"): breakThe outer game loop runs until "play" != "y", but here you use the variable "again".
Instead of this:
try: answer = int(input(f"{name} guess a number between 1 and 20: ")) if answer>= 1 and answer<= 20: break else: print("please only enter a number between 1 and 20") except ValueError: print("Please only enter an integer between 1 and 20")Use the exception you are already catching.
for count in range(1, 6): while True: try: guess = int(input("Guess a number between 1 and 20: ")) if guess < 1 or guess > 20: raise ValueError break except ValueError: print("Please only enter an integer between 1 and 20")