can only concatenate str (not “int”) to str

  Python, tkinter

Email

This code error in we are adding one string and one number

here we cannot add the string and number

Traceback (most recent call last):
File “C:/Users/root/Tkineter Project tutorial/venv/ad2.py”, line 5, in <module>
print(b+a)
TypeError: can only concatenate str (not “int”) to str

expl:

a = 3

b = "this string "

print(b+a)

right code:
a = 3

b = "this string "

print(b+str(a))
Spread the Code

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of