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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![sucqdslamp](https://secure.gravatar.com/avatar/7396616b3503d1ecae2141cadf316f15?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
sucqdslamp
279 PointsHello! I am very confused on how this code would run to output the letters. Can someone guide me step by step? Thanks!
Please guide me step by step as I am confused and stuck on this currently. Thanks!
1 Answer
![Zimri Leijen](https://secure.gravatar.com/avatar/b538d23e38fb61ef26b97583f481296c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zimri Leijen
11,835 PointsAssuming you mean this:
What would the output be of the following code?
print("A")
try:
result = 5 + 5
print("B")
except ValueError:
print("C")
except TypeError:
print("D")
else:
print("E")
print("F")
It would go line by line.
First, it does `Print("A")
then it will
try:
result = 5+5
print("B")
since there are no errors in this code, this code will run successfully
it will therefore execute print("B")
it will skip the except
statements because neither of those errors have been encountered, so it will resume at the else:
block
inside the else
block there's print("E")
finally there's a print("F")
command, that isn't in any of the blocks so that will always run.
hope that helps.
![sucqdslamp](https://secure.gravatar.com/avatar/7396616b3503d1ecae2141cadf316f15?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
sucqdslamp
279 PointsThank you very much! Understand it thoroughly now.
Zimri Leijen
11,835 PointsZimri Leijen
11,835 PointsIt would be a little easier to help if you'd link the challenge you're stuck with.
It's also good practice to at least make an attempt at solving it, and then showing your work and show where you got stuck.