Introduction

Introduction

Lists are a powerful feature of Python but most books and tutorials only scratch the surface. They teach you the basic syntax (the "what") but leave out practical examples (the "why"). This article goes beyond basic syntax and tries to show you the real power of lists.

So why aren't lists more widely used? When you first learn to program, the focus is on individual variables and objects. Lists require you to go beyond that way of thinking and see your data in "chunks" instead.

Many problems are best solved by manipulating lists of data. Python's list operators are a natural fit for these types of problems. They let you write solutions that are both compact and efficient. In short, by learning to "think in lists" you will become a better Python programmer.

Reasons to use lists

If you are looking for reasons to use lists in your programs, here are a few
  • lists are a built-in data type, so there is nothing to import
  • lists are efficient
  • lists make your programs shorter and easier to understand
  • lists let you write code with fewer bugs
  • lists are easy to search and sort with Python's built-in functions

No comments:

Post a Comment