中級 › TypeError: 'tuple' object does not support item assignment の原因と直し方 › パターン3
TypeError: 'tuple' object does not support item assignment の原因と直し方
タプルの要素を書き換えようとしたときに出るエラーです。
1 coords = _________ ^ 2 coords[2] = 9 3 print(coords)
Traceback (most recent call last):
File "main.py", line 2, in <module>
coords[2] = 9
~~~~~~^^^
TypeError: 'tuple' object does not support item assignment
空欄を埋めて実行を通す
後から要素を更新する前提のデータはタプルではなくリストで持つのが定石です。
次の問題