Using Lists
Apress eBooks · 2009
In this chapter, you will learn how to deal with multiple items of data by processing them in sequence. First, I’ll give you an overview of the data structures that Python provides that can contain more than one item. These include Strings, tuples, lists and dictionaries. There are a few actions that you can perform on all of these data types, so I’ll cover those before going into the details of creating and manipulating each type separately. In the second half of this chapter, you’ll be making a simple role-playing combat game. You will use these data structures to contain your player’s statistics and inventory and to translate the numerical results of the combat calculations into descriptive phrases. You’ll be using what you learned about loops in the previous chapter to work with the individual items in those data structures. In the process, I’ll cover some of the design and development issues you may have to face when creating more complex applications, and you’ll see how Python can be used to make repetitive number-crunching and text manipulation not only fast and painless but also entertaining! These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.