Code Fix

初級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

空欄を埋めて実行を通す

広告
広告スロット(未設定)

TypeError: can only concatenate str (not "int") to str の原因と直し方

Pythonの + は両辺の型が揃っていないと使えません。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)