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

Maor Beeri
Maor Beeri
2,154 Points

my code does not run

I get this message error:( except ValueError:
IndentationError: unindent does not match any outer indentation level) I still can't see where is my problem - it started to give my headache haha

here is my code I wrote:

import random

def game(): secret_num = random.randint(1,10) guesses = []

while len(guesses) < 5:
        guess = int(input("Guess a number between 1 and 10: "))

    except ValueError:
        print("{} is not a number".format(guess))


        if guess == secret_num:

            print("Yay you are correct, my number was {}".format(secret_num))

        elif guess < secret_num:

            print("my number is greater than {}".format(guess)

            print("my number is less than {}".format(guess))
    print("you didn't get it my number was {}

    play_again = input("Do you want to play again? Y/n")

    if play_again.lower() != n:
        print(" Good Bye!)


It would be helpful if you posted your code in your question so that we can see exactly what you are submitting. It seems as though your indentation is not correct but without seeing your code it is impossible to offer any further insight.

Steven Parker
Steven Parker
155,584 Points

To be able to check indentation, your code must be properly formatted. Use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.