Arrays and lists
Every language contains some form of data structure which allows you to store more than one value inside a variable. These tend to be called an array or a list. In python we call them lists. What is the difference between an array and a list? What is a data structure? Lost? Ok let us start from the beginning 
a1 = "bert" a2 = "sally" a3 = "fred" print a1, "is friends with", a2 print a2, "is friends with", a3
Here we have three people who we want to say are friends with one another. If we added a 4th friends we would have to add another two lines of code. If we added 10 more friends then we would need 20 more! If we had 1000… Well you get the idea! Clearly this is a dumb way to do it. The better way is to use an array. A array is a fixed length structure which allows more than one of the same type of data to be stored. In this case many strings. Let us see it in action
names = ["bert", "sally", "fred", "sue"] print names[0], "is friends with", names[1] print names[1], "is friends with", names[2] print names[2], "is friends with", names[3]
Rather than needing 4 variables we only use one. Because it contains 4 names we have to use a index (bit like accessing a letter from a string!). The numbering starts from zero (like a string!) and will always use the [] brackets.
Add “barny” to the above code to move onto the next exercise.
Output: (clear)











