Editor

Fix the Bug: String and Int Concatenation

Beginner · Fix the bug · from Python Type Conversion: How to Convert Between Data Types

From the lesson: Python Type Conversion: How to Convert Between Data Types

Imagine you ask someone their age and they write it on a sticky note. You now have the text "25" - but you can't do math with a sticky note. You need to read the text and turn it into an actual number in your head first.

Read the lesson

This code tries to build a message, but it crashes with a TypeError. Fix it so it prints:

You have 3 new messages

You can fix it any way you like (str(), f-strings, etc.).

count = 3
message = "You have " + count + " new messages"
print(message)

More Type Conversion exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz