初級 › TypeError: '>' not supported between instances の原因と直し方 › パターン2
TypeError: '>' not supported between instances の原因と直し方
文字列と数値、あるいはNoneと数値など、比較できない型同士を比較しようとしたときに出るエラーです。
1 score = ____ ^ 2 if score >= 60: 3 print("pass")
Traceback (most recent call last):
File "main.py", line 2, in <module>
if score >= 60:
^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'str' and 'int'
空欄を埋めて実行を通す
input()で受け取った値は常にstr型です。数値として比較する前にint()で変換する必要があります。
次の問題