Video 6: Lists Tuples Dictionaries (page 9 of 14) |
We have fewer methods and functions available with tuples relative to lists because tuples are immutable. For instance, we cannot reverse() or sort() the items in a tuple.
We can loop over the items in a tuple similar to how we loop over items in a list. We have the same indentation rules after the ":".
We may also cast or convert other collections to an immutable tuple by using the tuple() function. We may do this to write-protect our data or to improve looping performance.