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

Laknath Gunathilake
Laknath Gunathilake
1,860 Points

cant seem to pass this challenge

when I set the age to something greater than 13, I can pass the 1st task, but without it I cant. In the second task it says they will set the age for you, but I cant get through the second task

conditions.py
admitted= None
age= 
if age>=13:
      admitted='true'

I don't think that you can leave a variable undefined. Try assigning it to an age. Also the challenge is asking you to define admitted = True instead of admitted = 'true'.

1 Answer

Hello Laknath,

I just checked the problem, Kenneth is going to create an age variable for you, so you really don't have to create one. On the other hand, your first statement is correct and that is why you are passing the first challenge, but now, in the second challenge you have to make the else statement to set admitted = False.

By the way, it is True, not 'true'.

Does that make sense?

Let me know :)

Laknath Gunathilake
Laknath Gunathilake
1,860 Points

Daniel, thank you for the comment. I tried the following, but it says "invalid syntax (<string>, line 1)" ..... admitted = None age= if age>=13: admitted=True else: admitted=False ......

Is this similar to what you have?

admitted = None

if age >= 13:
  admitted = True
else:
  admitted = False

But do you understand it?

Laknath Gunathilake
Laknath Gunathilake
1,860 Points

Yes I do, I left the age variable undefined in line 2. Instead I should have done age>=13: