Thomas Weidner wrote: > I started lerning Python and discovered tuples, but why do they exist ? > What's the difference from a list ? did you remember to check the FAQ? http://www.python.org/doc/FAQ.html#6.15 Q. Why are there separate tuple and list data types? also consider this code fragment: >>> T = (1, 2, 3) >>> L = (1, 2, 3) >>> D = {} >>> D[T] = "spam" >>> D[L] = "spam" Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: unhashable type >>> T.append(4) Traceback (innermost last): File "<stdin>", line 1, in ? AttributeError: 'tuple' object has no attribute 'append' >>> L.append(4) >>> L [1, 2, 3, 4] Cheers /F
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4