Fix All the Bugs
Beginner · Fix the bug · from How to Read Python Error Messages and Fix Common Bugs
From the lesson: How to Read Python Error Messages and Fix Common Bugs
When beginners see a red error message, their first instinct is panic. The screen fills with scary-looking text, and they think they broke something badly. But here's the truth: error messages are your best friend. They tell you exactly what went wrong and where.
Read the lessonThis code has THREE bugs (one per section). Fix all of them so the output is:
Student: Alice
Grade: 85
Passed: True# Bug 1: Something wrong with the variable name
student_name = 'Alice'
print(f'Student: {student_Name}')
# Bug 2: Something wrong with the type
grade = '85'
print(f'Grade: {grade + 0}')
# Bug 3: Something wrong with the comparison
passed = grade >= 60
print(f'Passed: {passed}')
More error messages exercises
- Fix the SyntaxErrorBeginner
- Fix the NameErrorBeginner
- Fix the TypeErrorBeginner
- Fix the IndexErrorBeginner
- Fix the ValueErrorBeginner
All Python exercises · 50 practice problems · Control Flow quiz