40.8k views
2 votes
Why does this code raise an error:
print("1234"+5678)

1 Answer

3 votes
The code raises an error because you are trying to concatenate a string and an integer. To fix it, you can convert the integer to a string before concatenating it with the other string. Here's the corrected code:
print("1234" + str(5678))
User Fabian Schmick
by
7.5k points