Python/error debug
TypeError: can only concatenate str (not "int") to str
kimble2
2024. 8. 17. 11:15
반응형
Addition Between Incompatible Types
Problematic Code:
result = "The number is: " + 5
Error Message:
TypeError: can only concatenate str (not "int") to str
Solution: You need to convert the integer to a string before performing the addition.
result = "The number is: " + str(5)
Alternatively, you can use string formatting to insert the variable.
result = f"The number is: {5}"
반응형