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 revision Previous revision
programming:python:syntax:collections:tuples [2024/03/01 07:37]
niziak ↷ Page moved from programming:python:syntax:types:tuples to programming:python:syntax:collections:tuples
programming: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>​