meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
programming:python:syntax:collections:tuples [2024/03/01 07:37] – ↷ Page moved from programming:python:syntax:types:tuples to programming:python:syntax:collections:tuples niziakprogramming:python:syntax:collections:tuples [2024/03/01 08:51] (current) niziak
Line 16: Line 16:
 </code> </code>
  
 +===== "Change" items in tuple =====
 +
 +Tuples are immutable. Only way is to create new tuple using temporary list.
 +
 +<code python>
 +t = ('a', 'b', 'c')
 +t_new = t + ('d', 'e', 'f')
 +
 +l = list(t)
 +
 +l.insert('d', 'e', 'f')
 +l[1] = 'bb'
 +l.remove(0)
 +
 +t_new = tuple(l)
 +</code>