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

How to end a condition statement

I want to make an action that takes place only if a conditional statement is true. After that, I want another independent action but I can't seem to make independent and end the condition. How can I do that?

2 Answers

If I understand the question properly you simply unindent after the if

if True:
   print('condition_true')
print('some_independant_function')

That's what suppose to happen but from some reason in the treehouse workspace it doesn't let me remove the indentation from the second print so it stays in the if

hmm that is odd, I might suggest trying another browser... I havent used workspaces a ton but shift+tab is standard for un-indent, that may work instead of deletion. You could possibly try this:

if True:
   print('condition_true'); break
print('some_independant_function')

but you may still run into indentation issues

I will try break thanks