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 trialcory woods
2,568 PointsHow do you know what is supposed to print?
how do I know what should print without a function or variable with assigned values?
2 Answers
Steven Parker
231,269 PointsAll the print statements in the quiz examples put out literal strings (like this one:βprint("A")
Β ), so no variables or functions or needed.
You task is to anticipate how the program flow will be redirected by the "try" and "except" statements, and determine which of the print statements will run. From there, you can determine what the output will be since each statement that runs will output a single letter.
rydavim
18,814 PointsYou'll want to walk through the code step by step for each question. Try going one line at a time and thinking about what would happen when it runs. This method should work for both questions, but here is an example below.
print("A") # does this print?
try:
result = 5 + 5 # does this raise a ValueError or TypeError?
print("B") # depending on whether an error is raised, does this run?
except ValueError:
print("C") # did you trigger a ValueError?
except TypeError:
print("D") # did you trigger a TypeError?
else:
print("E") # if no errors were triggered, does this run?
print("F") # does this print?
Hopefully that gives you a place to start, but please let me know if you still have questions and we can walk through a solution. Happy coding!