Good. We already know some basic data types: integers, floats, and strings. Now, we want to analyze multiple values – for instance, the top six European companies by revenue. You could start by defining six separate variables like this:
company_1 = 'Royal Dutch Shell'
company_2 = 'BP'
company_3 = 'Total'
But that's a lot of typing. Besides, it's difficult to handle groups of data stored in this way. Python offers a few ways to store multiple values in a single variable. The most versatile one is called a
list. Take a look:
companies = ['Royal Dutch Shell', 'BP', 'Total', 'Volkswagen', 'Glencore Xstrata', 'Gazprom']
A list begins and ends with a bracket. Inside these brackets are comma-separated elements. Because our elements are strings, we also need to surround them with quotes.