初級 › TypeError: can only concatenate str (not "int") to str の原因と直し方 › パターン2
TypeError: can only concatenate str (not "int") to str の原因と直し方
文字列と数値を + で連結しようとしたときに出るエラーです。
1 count = 5 2 print("count=" + ___________) ^
Traceback (most recent call last):
File "main.py", line 2, in <module>
print("count=" + count)
~~~~~~~~~^~~~~~~
TypeError: can only concatenate str (not "int") to str
空欄を埋めて実行を通す
「数字に見えるから文字列」ではありません。countはint型なので、そのままでは文字列と連結できません。
次の問題