Python Python Basics (2015) Number Game App Number Game Refinement

Siddharth Pande
Siddharth Pande
7,493 Points

kindly find the *** i am doing it wrong

     import random

def game():
    guess_num = random.randint(1, 10)
    print(guess_num)
    chance_left = 5
    count = 1
    print("Guess a number between one and ten and try your luck.")
    print("""
Number of chances left is {}
""".format(chance_left))
    while True:
        chance_left -= 1
        try:
            user_num = int(input("Enter any Number from 1 to 10: > "))
        except ValueError:
            print("That's not a valid number! Kindly enter a number only")
            print("Number of chance left is {}".format(chance_left))
            count += 1
            continue
        if user_num == guess_num:
            print("""
You got it. My secret number was {}
""".format(guess_num))
            break
        elif count >= 5:
            print("""
5 chances completed. You've lost this game!
""")
            choice = input("""
If you want to play again Enter 'Y', if not Enter 'N'
> """ )
            if choice.upper() == "Y":
                game()
            else:
                print("""
Thank you for Playing. Good Bye!
""")
                break
        else:
            if user_num < guess_num:
                print("""
Too Low. Try again!
""")
            else: 
                print("""
Too High. Try again!
""")
        count += 1
        if chance_left != 1:
            print("""
Number of chances left is {}
""".format(chance_left))
        else:
            print("""
This is your last chance
""")

game()
Prince Canty
Prince Canty
2,135 Points

you indented your import