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
Alex Kravchenko
1,278 PointsCan someone help me under ```Except ValueError as err:```?
I specifically don't understand as err. What is it for? It seems like if you have one exception handling line, then you just leave it there with your print statement. But if you are adding a second one, you have to use the as err, and then you have to format it into your print statement. I don't understand why, whatsoever. I've seen it like 3 times in my lesson but it was never explained why we use it. For example (imagine this makes sense, there was something I did written just like this in a course):
try:
message = print(int("What's your favorite color? "))
except TypeError:
print("Oh no, something went wrong")
except ValueError as err:
print("This isn't right {}" .format(err))
i tried google but nothing explains it in english.
1 Answer
<noob />
17,063 Pointswe use err to print the exact system massege that causes the excpetion.