Le TUPLE, une liste protégée et immutable
mes_affaires est une liste entre crochets [ ]
mes_fringues est un tuple entre parenthèses ( )
Un tuple est non modifiable !!!!
>>> mes_affaires = ["chemise","pantalon","chaussures"] >>> mes_affaires ['chemise', 'pantalon', 'chaussures'] >>> mes_affaires[0] = "t-shirt" >>> mes_affaires ['t-shirt', 'pantalon', 'chaussures'] >>> mes_fringues = tuple (mes_affaires) >>> mes_fringues[0] = "veste" Traceback (most recent call last): File "<pyshell#42>", line 1, in mes_fringues[0] = "veste" TypeError: 'tuple' object does not support item assignment >>> mes_fringues[0] 't-shirt' >>> mes_fringues.append ("ceinture") Traceback (most recent call last): File "<pyshell#44>", line 1, in mes_fringues.append ("ceinture") AttributeError: 'tuple' object has no attribute 'append' >>> mes_affaires.append ("ceinture") >>> mes_affaires ['t-shirt', 'pantalon', 'chaussures', 'ceinture'] >>>