옵티새벽 | 디지털 마케팅 & 광고 전략

[파이썬] TypeError: can only concatenate str (not "int") to str 본문

자격증 실기 & 필기 🔵

[파이썬] TypeError: can only concatenate str (not "int") to str

옵티새벽 2022. 1. 21. 18:50

파이썬 프로그램 사용시 문자열과 숫자열을 아래와 같이 기입할 경우 오류뜨네요.

첫번쨰 사진과 다르게 num = str(2) 라고 설정 후, print(first_name+num) 하고 run 눌러보니..그때서야 원하는 답이 나오더라구요...

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

이런 오류가 뜰 경우는!!

1번방식 or 2번방식으로 풀어서 기입하면 풀린다.

 

1번 num = str(2) 

2번 num = '2'