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 lessonThis code tries to build a message, but it crashes with a TypeError. Fix it so it prints:
You have 3 new messagesYou 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
- String to Int and MultiplyBeginner
- Float to Int: What Gets Lost?Beginner
- Predict the Output: Type ConversionsBeginner
- Safe Number ConverterBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz