TypeError: 'tuple' object does not support item assignment when swapping values

前端 未结 1 475
陌清茗
陌清茗 2020-12-08 12:45

I am writing a simple sort program in python and encounter this error. I want to swap list elements but it returns an error. I am attaching the error and program in question

相关标签:
1条回答
  • 2020-12-08 13:30

    Evaluating "1,2,3" results in (1, 2, 3), a tuple. As you've discovered, tuples are immutable. Convert to a list before processing.

    0 讨论(0)
提交回复
热议问题