July 2017
Beginner to intermediate
420 pages
10h 56m
English
Tuples are just like lists, except they're immutable, so you can't actually extend, append, or sort them. They are what they are, and they behave just like lists, apart from the fact that you can't change them, and you indicate that they are immutable and are tuple, as opposed to a list, using parentheses instead of a square bracket. So you can see they work pretty much the same way otherwise:
#Tuples are just immutable lists. Use () instead of []x = (1, 2, 3)len(x)
The output of the previous code is as follows:
3
We can say x= (1, 2, 3). I can still use length - len on that to say that there are three elements in that tuple, and even though, if you're not familiar with the term tuple, a tuple can actually contain as many elements ...
Read now
Unlock full access