Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and The Cloud
by Paul J. Deitel, Harvey M. Deitel
5.18 Wrap-Up
This chapter presented more details of the list and tuple sequences. You created lists, accessed their elements and determined their length. You saw that lists are mutable, so you can modify their contents, including growing and shrinking the lists as your programs execute. You saw that accessing a nonexistent element causes an IndexError. You used for statements to iterate through list elements.
We discussed tuples, which like lists are sequences, but are immutable. You unpacked a tuple’s elements into separate variables. You used enumerate to create an iterable of tuples, each with a list index and corresponding element value.
You learned that all sequences support slicing, which creates new sequences with subsets of the original ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access