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 trialMoe Myint Kyal Sin
Courses Plus Student 553 PointsHow can I correct errors?
https://teamtreehouse.com/library/python-basics/python-for-beginners/correct-errors How can I correct errors of the question?
print("Hello")
print(name)
NameError
print("Let's do some math!")
print(5 + "a")
print("Thanks for playing along!')
1 Answer
Ari Misha
19,323 PointsHiya Moe!! I'd only mention the lines of codes that needs to be rectified so yeah here we go:
print(name)
- This line of code will throw an error 'coz the variable "name" is not defined. Python tryna find this variable and it couldnt so it threw an Error. To prevent this bug, all you have to do define the "name" variable and assign anything to this variable.
print(5 + "a")
- In Python, this line of code will throw a "TypeError". Why? Its coz ya cant add an integer to a string. So yeah to prevent this bug , just convert "5" to a string.
print("Thanks for playing along!')
- this line of code will throw a SyntaxError coz you've to be consistent with quotes. If you've opened a string with a single quotes , then end it with a single quote as well. And same goes for double quotes. I'd recommend ya to stick with double-quotes in python.
Consider these suggestions and your code will pass with flying colors. (:
Moe Myint Kyal Sin
Courses Plus Student 553 PointsMoe Myint Kyal Sin
Courses Plus Student 553 PointsThank you so much for helping Ari. That's really help. :)
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsI'm marking this answer as best because the other one was a straight copy/paste, and this is the only remaining answer to the question. If someone else posts an answer and the OP decides that the new answer is better, they can feel free to change it