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 Wrap Up

Mercedes Aker
Mercedes Aker
6,544 Points

Python Basics quiz question

Quiz Question 5 of 5 There is a keyword missing that allows you to have access to the exception that was caught.

correct_answers = input("How many correct answers did you get? ") try: correct_answers = int(correct_answers) except ValueError ___ err: print("Whoops! Try again: {}".format(err)) What keyword is missing?

The answer to this quiz question was "as" but I don't understand where it goes in the code and why its needed. Any explaination?

1 Answer

Steven Parker
Steven Parker
231,275 Points

The "as" keyword causes the variable that follows it to be assigned with the data associated with the exception (known as the "exception argument"). In this example, it contains a string that gets included in the output message.