 Here are some other methods you can use with lists First let's make an empty list by putting two square brackets next to each other and Show that it's empty If we want to add a number to the list we use append If I say numbers dot append ten now, there's a ten in the list Let's add another number and append an eleven at the end of the list Now there's two items and We'll go with one more here Notice that append changes the list. It does not create a new one If you want to add more than one item at a time you can use addition to add one list to another list I can say numbers should refer to the old value of numbers plus the list 13 14 15 and Now numbers has the numbers 10 through 15 in it The pop method removes the last element of the list If I say last entry equals numbers dot pop Last entry will have the number 15 in it and numbers no longer has it in there You can also pop an entry in the middle of a list Let's say mid entry equals numbers dot pop to If we look at mid entry it gets the 12 Numbers no longer has the 12 in it Rather than use slices to insert elements into a list you can use the insert method giving the index number and the new value I Can say numbers dot insert at position 2 I want a 12 and At position 0 I'll put a 9 Insert inserts only one item at a time Unlike slices where you can add as many items as you need Okay, that handles our laundry list of functions Let's write a program that will ask users for numbers until they enter a negative number and store all those numbers in a list We'll then find the average and print it and then find out how many numbers are below the average Exactly average and above average and display that as well First the function to get the numbers. It's going to return a list of numbers as a result So start with the empty list and Then set up the loop We're not finished yet and as long as we're not finished We have to ask the user for some input enter a number or a negative to Finish not great phrasing, but we can work on that later If the number they entered is non negative Then we can append it to our result list otherwise We have a negative number and we're finished And we can return the result list By the way during these videos you may hear me say the word array instead of list That's because the idea of a list is called an array and a lot of other programming languages And I teach a couple of courses so every once in a while I'll use their nomenclature of array rather than the Python nomenclature of a list So bear with me and whenever you hear array Think oh, that's a Python list Let's run this program and test it. We'll have a test list equals get numbers Let's give it a three a four and eight seven and a two and a negative one and If we look at test list There are numbers It's working great Now we need the function to find the average of the numbers in the list So we're going to calculate the average of some list of data in This case we'll set the sum to zero and then for each item in the data list We're going to add it on to the sum To get the average we need the number of items in the list and that's the len function We take the length of our data if the number is equal to zero Which means they gave us an empty list to start with we'll just set the average to zero The average of an empty list is zero that seems a good compromise Otherwise the average is the sum divided by the number of items and We return the average Let's test that Let's make our test list in this case 10 plus 15 is 25 plus 11 is 36 Let's set average to be calc average of Our test list So it looks like that function is working pretty well and now our main program We're going to create a data list which we'll get from get numbers We'll calculate the average Which is the calculated average of our data list and then we'll print the average is And let's use formatting here to make it look nice to three decimal places Whatever the average is Before we go further. Let's test that to see if it works And again, I forgot to invoke main So let's do that and run again If I take 10 11 and 15 and then negative 1 The average is 12 good Now we need to go through the list again counting the number of items in each category The number of items above the average so far is zero The number below is zero and the number equal to the average is zero For each item in the data list if the item is greater than the average Then the number above Becomes one greater Otherwise if the item is less than the average the number below Plus and becomes one if it's not greater or less it must be equal and so the number equal is Incremented by one Finally, we need to display those results We'll print number of items below average The number below the number of items equal to average and Pardon my typing errors here is an equal and The number of items Above average Will be n above let's clear the shell and run the program this time. Let's do 10 11 12 and 15 and that The average is 12 two of them are below one is equal to the average and one is above average And there's our program that shows lists in action