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 Python Basics (2015) Logic in Python Conditional Value

Arun Patel
Arun Patel
1,180 Points

Need help regarding the syntax

Please clarify what is wrong with the syntax

conditions.py
admitted = None
age = 15
if age >= 13:
    ...     admitted = bool(1)
else:
    ...     admitted = bool(0)

3 Answers

Hi Arun,

Your syntax is fine; I don't think you want the ellipsis in there - so lose the ....

Also, you've overridden the age variable. Don't set it to a value; that's what the tests of the challenge will do. If you set it to 15, then the test checking the outcome of age being less than 13 will return the wrong result.

This works fine:

admitted = None
if age >= 13:
    admitted = bool(1)
else:
    admitted = bool(0)
Arun Patel
Arun Patel
1,180 Points

Thanks Steve. I changed and below syntax worked.

admitted = None
if age >= 13:
    admitted = bool(1)
else:
    admitted = bool(0)

I was bit confused since in the tutorial while showing on Workspaces, ellipses were shown for indentation for both if and else. Also the ellipses are automatically added if I use Python shell. Any specific reason why the shell for code challenge doesn't support ellipses?

You can also use admitted = True rather than admitted = bool(1).

I have never come across full stops being added in Workspaces or IDEs. Maybe there's an option to show whitespace as a dot just to reinforce the indentation visually, rather than actually adding a full stop character? I can't get the Workspace to do this, even with "Indent Guides" selected.

I've just watch the video ... this is in the python shell, so a live interpreter. The prompt changes from >>> to ... to indicate that the code hasn't concluded, i.e. you're in the middle of an if block or a loop. This doesn't translate into the text of a file. It just indicates that the prompt in the shell is waiting for a conclusion to the code block before it will execute it.

Sorry for the confusion!

Arun Patel
Arun Patel
1,180 Points

Thanks Steve for the clarification. Being new to Python these fundamentals really help.

No problem, Arun. :+1:

Enjoy the course - Python is pretty powerful so you work through some pretty advanced uses of Python within the courses here.

Good luck!

Steve. :smile: