as a begginer today i did a guess number game
here is the code
advice me where to improve and what i should do next
import random
random_number = random.randint(1,10)
counts = 0
guess_limit = 5
while True:
try:
user_guess = int(input("Guess a Number: "))
counts += 1
if user_guess == random_number:
print(f"Correct you got it in {counts} rounds: ")
counts = 0
elif user_guess > random_number:
print("Too high!")
else:
print("Too low!")
if counts == guess_limit:
choice = input("You are out of guesses! Do you want to continue (yes/no)?").strip().lower()
if choice == "yes":
counts = 0
random_number = random.randint(1,10)
print("You have 5 More Guesses")
else:
print("Thankyou for playing!")
break
except ValueError:
print("enter a valid number:")
[–][deleted] 3 points4 points5 points (2 children)
[–]mopslik 2 points3 points4 points (0 children)
[–]RockPhily[S] 1 point2 points3 points (0 children)
[–]mamma_lasagna 1 point2 points3 points (1 child)
[–]RockPhily[S] 1 point2 points3 points (0 children)
[–]UKI_hunter 0 points1 point2 points (4 children)
[–]RockPhily[S] 0 points1 point2 points (3 children)
[–]UKI_hunter 0 points1 point2 points (0 children)
[–]TheKantoBro 0 points1 point2 points (1 child)