Chapter 5: Lists and Dictionaries: The Hangman Game


Download CD Content

Overview

Tuples are a great way to work with sequences of any type, but their immutability can be limiting. Fortunately, another sequence type, called lists, do everything that tuples can, plus more. That's because lists are mutable. Elements can be added or removed from a list. You can even sort or reverse an entire list. You'll also be introduced to another type, dictionaries. Whereas lists work with sequences of information, dictionaries work with pairs of data. Dictionaries, like their real-life counterparts, let you look up one value with another. Specifically in this chapter, you'll learn to do the following:

  • Create, index, and slice a list

  • Add and delete elements from a list

  • Use list methods to append, sort, and reverse a list

  • Use nested sequences to represent even more complex information

  • Use dictionaries to work with pairs of data

  • Add and delete dictionary items




Python Programming for the Absolute Beginner
Python Programming for the Absolute Beginner, 3rd Edition
ISBN: 1435455002
EAN: 2147483647
Year: 2003
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net