본문 바로가기

프로그래밍 - 활용/에러

[Python] 출력시 int와 str을 함께 사용할 때 발생

📌 에러 이름

TypeError: can only concatenate str (not "int") to str

 

 

예를 들어

print("add: "+(3+4))

라는 코드에서 에러가 발생하는 것이다!

 

🔎 해결 방법

print에선 모두 같은 자료형으로 통일해주기
print("add: "+str(3+4))