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

Abdul-Rahman Dambazau
Abdul-Rahman Dambazau
216 Points

If statement error

Script: Points=int(input("How many points does it usually take a team to avoid relegation from the premier league?")) if Points >= 40: print("Correct!")

This is what I get when I run the code:

treehouse:~/workspace$ python if.py
File "if.py", line 2
age = int(input("What is your age? "))
^
IndentationError: unexpected indent
treehouse:~/workspace$

Abdul-Rahman Dambazau
Abdul-Rahman Dambazau
216 Points

Please let me know what I need to fix in the code. Thank you.

Can you post all of your code and use markdown? See the cheatsheet below. You should have three backticks and the word python ```python before your code and three backticks after your code. The backtick key is just to the left of the number 1 on the keyboard. It will make it a lot easier to help, especially with indentation errors and with an error on line 2.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

On an indention error or a invalid stream error, the actual cause is usually the statement before the line reported in the stacktrace message.

1 Answer

Steven Parker
Steven Parker
229,644 Points

The error message refers to a part of the code that is not shown in your sample.

It's apparently on the second line of the file "if.py", and it is indented when Python expects it to not be. Or as Chris suggested, there may be a problem on line 1 that is being misreported.

Abdul-Rahman Dambazau
Abdul-Rahman Dambazau
216 Points

Thank you. I figured it out eventually.