Hello, my name is Nizar Dajani, and in these lessons, you will learn about lists, dictionaries, tuples, and sets, and in this lesson, you'll learn about lists. In Python, lists are one of the most commonly used data structures to store and manipulate data. Lists are ordered, mutable, and can contain elements of different data types. Here are some fundamental operations for creating and manipulating data using lists. First, it's common practice to create an empty list and then start adding items to it. And here are two ways to create an empty list. List items are stored between brackets, and so if I have empty brackets, then this is an empty list, and I sign it a variable name of empty underscore list. I can also call the Python built-in function, which is called list, and this will create an empty list for me as well. Then I'll assign it to this variable, and now I'll print out both lists to confirm that they are indeed empty. So let me run this code, and I do get blank brackets, so these two lists are indeed empty. Now that I have my list, I can add items to it. I can update existing items, I can delete items, and I can iterate through them as well. So in my next code example, I have a list that contains multiple items of different data types, which is allowed. And now I want to grow this list and add to it. So I'll call the append method of my list class, and inside the parentheses, I pass the value that I want to add, which is an integer of 25. Then I follow it with a print statement to display the updated list. So let's run this code to verify the change. And there we see that 25 has been added to my list. Now notice that the newly appended item was added at the end of my list. What happens if I wanted to add it to the beginning of my list, or somewhere in the middle of my list? For that, I can use the insert method. In my next code example, I call the insert method, and it takes two arguments. The first argument is the index location. And remember that indices are zero based. Then the second argument is the item to add to the list. So say I want to add the string orange, right before apple. Then let's figure out what index location that would be. I have index zero, index one, index two, and so I want to place orange in index three. And that's what I have in my code example. I pass the value three from index location and the string of orange. Then I print my list to see if the changes were correct. So let's run this code. And there we go. The item orange has been added right before apple. Now how about if I change my mind and need to update the value that I just added from orange to say banana in my next line of code, I call my list by name, and inside the bracket, I pass it the index location of the item I want to update. And since I already know that orange is an index tree for my last example, then you see that this is the value that I use. Then I set it equal to a new value that I want to use, which in this case is banana. Then I print my list once again to verify my changes. So let's run this code. And now orange has been changed to banana. So lists are mutable, meaning that they can be changed. And just like we can add and update items, we can also remove them. My next code example will use the pop method. This will remove the last item in my list. So this will attempt to remove the integer 25. And as you can see, the pop method doesn't take any arguments. Then I have a print statement to verify my changes. And so let's run this code. And now integer 25 has been deleted from my list. But what if I don't want to remove the last item in my list, but instead I want to remove another item? Well, there are a couple of ways to remove a particular item from a list. We could remove it by specifying the index location of the item that we want removed. Or we can use the name of the item directly. When using the index location option, I can still use the pop method, but pass it the index location. So in my next code example, just like I added banana to index location three, I can also remove it using the pop method. And passing it the argument number three. And to confirm this is correct, I will print out my updated list. And so let's run this code to verify the changes. And there we go. There is no longer a banana item in my list. If you are not too fond of using indices and prefer to remove an item from the list by its value, then we can use the remove method. In my next code example, I call the remove method and pass it the actual value of the item that I wish to remove, which I'll use Apple in this case. Then I'll print out my list to confirm the changes. So let's run this code to verify it. And indeed, Apple has been removed from my list successfully. I can also work on my data to manipulate it some more. For example, I currently am left with a list of integers. Well, what if I want to reverse the order of my integers? Well, in my next code example, I called the reverse method on my list without passing any argument. Then I print it out. So let's run this code to confirm that my list has been reversed. And yes, now the order of my integers are in reverse order from biggest smallest. And if I want to properly sort these items back in normal ascending order, I can use the sort method on my list. In my next code example, I do just that. Here you can see that I call this sort method on my list without passing any arguments. Then I print out my list to see the changes. So let's run this code to verify it. And my list is now sorted from the smallest to largest integer. It is also common to loop through data in my list. And in my next line of code, I have a new list called fruits, which contains Apple, Banana and Cherry. Then I have a for loop, which iterates through the fruits list and uses an iteration variable called fruit. And on each iteration, it will execute this one line of code, which is to print the fruit. So let's run this code. And I get each item printed out as expected. Another common practice when working with data in a list is to check if some value can be found in the list. So in my next code example, I have my same fruits list with Apple, Banana and Cherry. Then I use an if statement and the in keyword in Python, which is used to check if a value exists in a sequence, like a list, Apple, string and so on. In this case, it checks if Apple is present in the fruits list. If Apple is indeed in my list, then I execute this line of code. But if it's not found in my list, then I execute the else statement. So let me run this code. And yes, since I know Apple is in my list, then I get this correct message. Now please remember that Python is case sensitive. So Apple with a capital A is not the same as Apple with a lowercase A. And if I change Apple in my if statement to be with a capital A, then run this code again. I now get the else treatment because Apple with a capital A is not part of my list due to case sensitivity. So in this lesson, you learned about manipulating data using lists. And in the next lesson, you will learn about manipulating data using dictionaries. Thanks for watching.