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 All Together Now Handle Exceptions

How come this alternative code has an indentation error?

https://w.trhou.se/9owaya1qj3 I think it is because I have an if statement within a try statement, and an else statement(that is paired with the if statement) within another else statement(paired with try statement)

2 Answers

There is no try in the code you shared. Did you share the correct file?

Sorry about that here is the right one https://w.trhou.se/dfx4pypgvp and its on the masterticket.py file

I'm pretty darn sure that you can't mix and match code blocks like that. If you start an if statement in a try block, you have to finish that if statement in the same try block. So any elses or elifs have to be in the same block.

It's the same the other way around. So you can't do

if
   try
else
   except

The try and except would have to be in the same if block.