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 trialSohail Mirza
Python Web Development Techdegree Student 5,158 Pointsunable to understand the syntax regarding valueError
I am a bit confused about why we need quotations after parenthesis why is it not print("{}").format(err)) instead in the video it shows print("{})".format(err))
except ValueError as err: print("Oh no! Thats not a valid value") print("{})".format(err))
1 Answer
Sheila Anguiano
Full Stack JavaScript Techdegree Graduate 35,239 PointsHello, Just to clarify, you're wondering why the code block is:
except ValueError as err:
print("Oh no! That's not a valid value. Try again..")
print("({})".format(err))
And not
except ValueError as err:
print("Oh no! That's not a valid value. Try again..")
print("{}".format(err))
If that's the case, I'll recommend you try using the same values using the first code and then trying without those parenthesis. You'll notice that is merely aesthetic in this case. But if you try to delete the quotations, then you'll get an error, because quotations make a STRING and those can be formatted with the .format method.
Just try experimenting and moving this around, and also keep in mind style it makes things easier to read for everyone else