Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Can someone tell me why im getting this error for this code? Python

import random def jason(): secret_num = random.randint(1,10) guesses = [] while len(guesses) < 5: try: guess = int(input("guess a number between 1 and 10: ")) except ValueError: print("{} is not a number".format(guess)) else:

        if guess == secret_num:
            print("you got it! my number was{}".format(secret_num))
            break
        elif guess < secret_num:
            print("to low my number is greater than {}".format(guess))
        else:
            print("to high my number is lower than {}".format(guess))
        guesses.append(guess)
else: 
    print("not this time, my number was {}".format(secret_num))
play_again = input("do you want to play again? yes or no")
if play_again != "no":
else:
    print("see you later!")

i'm getting this error, i indented the else, that did not fix it, but i want it to say that print so wouldn't it need to stay where it is anyways?

File "number.py", line 24
else:
^
IndentationError: expected an indented block

line 24 is the very bottom else of the code

Steven Parker
Steven Parker
229,644 Points

Try formatting your code so we can see the actual spacing.

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.