Editor

Fix the NameError

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 lesson

This code has a NameError. Find the typo and fix it so it prints:

Hello, Alice! You have 3 new messages.
user_name = 'Alice'
message_count = 3
print(f'Hello, {user_name}! You have {mesage_count} new messages.')

More error messages exercises

All Python exercises · 50 practice problems · Control Flow quiz