Skip to content
Quantoros

Why does atuple[i] += [‘item’] raise an exception when the addition works?

PythonLevel: Advanced

Why does a_tuple[i] += [‘item’] raise an exception when the addition works?

Hints
  • Identify object types, mutability and execution order.
  • Trace a minimal example: which values and references change?

Answer

This answer is part of mentoring

Advanced questions come with a full breakdown and a mock interview with a working quant researcher. The first call is free.

Source and licence: Python 3.14.0 Programming FAQ — Python Software Foundation · PSF-2.0

Related questions