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

Python Basics IF challenge Task 1 and 2

Hi,

In the Python Basics IF challenge tasks 1 & 2 I can't understand what to do.

"I'm going to create a variable named age. I need you to make an if condition that sets admitted to True if age is 13 or more."

I did:- admitted = True age = 13 if age >= 13: print("True")

The above code went successful but I have tried many options to resolve the second task I can't get through. I tried ELSE and ELIF, don't know if both will used or only ELSE.

"Add an else to your if. In the else, set admitted to False."

Thank you in advance.

8 Answers

It is asking you if age is greater than 13 admitted = True:

if age > 13:  #if age is greater than 13
    admitted = True  #than admitted = True

I don't think any of you helped. He was asking about the second part.

Did you read his code and the challenge?

Jeremy Kerrigan
Jeremy Kerrigan
12,002 Points

admitted = None if age >= 13: admitted =[1]

Tomasz Necek
PLUS
Tomasz Necek
Courses Plus Student 7,028 Points

admitted = None age = 14 if age >= 13: admitted = True

Michael Guthrie
Michael Guthrie
1,924 Points

I had similar issue. I fixed it by reformatting my text to be in line with the first task.

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

Isaac Rosa
PLUS
Isaac Rosa
Courses Plus Student 1,744 Points

it's actually |

if age >= 13: admitted = True

I hit a speed bump on this one also but reading this helped me find the answer thanks

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

Fun Fact

This won't pass the coding challenge due to the constraints placed on the validators, however this reduces the need for garbage collection and the number of instructions the processor has to interrpret.

admitted = (False, True)[age >= 13]

Commenting Tip

Just so you know.... To make it easier on those who read your code

Single Grave Accent -- on either side encompassing the text -- Backtick key is located next to the '1' below the Esc key

Tripple Grave Accents

```  <--- Triple Grave Accents
[Code here]
```

To make it colorful:

```python3  <--(whatever language you are using)
[Code here]
```
print("I am using python syntax highlighting here")

admitted = None if age >= 13: admitted = True