TypeError: can only concatenate str (not "int") to str
문자와 숫자를 같이 출력하기 위해서 아래와 같이 작성해서 실행했습니다.
count = int(input())
for i in range(count):
a,b = map(int, input().split())
print("Case #" + (i+1) +": " + a + " + " + b + " = " + (a+b))
그러나,
이와 같은 TypeError가 났습니다.. 문자와 숫자를 같이 쓸 수 없기 때문에 나타난 오류였습니다!!
즉, print 할 때는 같은 자료형만 가능합니다!!!
숫자 부분을 str(숫자) 와 같이 변경해 출력했습니다!!
count = int(input())
for i in range(count):
a,b = map(int, input().split())
print("Case #" +str(i+1)+": " + str(a) + " + " + str(b) + " = " + str(a+b))
728x90
반응형
LIST
'Error' 카테고리의 다른 글
[Error] Browserslist: caniuse-lite is outdated. (0) | 2024.11.11 |
---|---|
[ERROR] Some of selected resources were not added to version control / Some of selected resources were not committed (0) | 2022.06.17 |
댓글