I get this question quite a lot, especially when people learn about topples for the first time. What are the differences between topples and lists? Well, let's get straight to the point. The first and most important difference between the two data types is that tuples are immutable. So let me write this here as a comment. topples are immutable.
Once lists are mutable, so let me write this as well. Lists are mutable. Again, topples cannot be modified after creation, like adding, updating or removing any of its elements, whereas lists allow you to perform such operations on their elements. Generally speaking, you can think of topples as being immutable lists. As a consequence of topple immutability, it's easy to conclude that a topple has a fixed length. Once a list has a variable Length since we can add or remove elements to or from a list, so let me add this as well.
Fixed length versus variable length. Next, an obvious difference between the two data types is the syntax. The elements of a topple are enclosed by parentheses. So let me write this topples, we have parentheses, whilst lists use square brackets to hold their elements. So lists we have square brackets. Okay.
Last but not least, a topple has less available methods and operations analyst. In order to verify this, we can use the built in dir function in Python. First, let's create a topple and the list. So let's say a equals open and close parentheses and B equals open and close square brackets. Let's check type of a and also type of B. So we have a topple and the list both of them Being empty at this point, it doesn't matter if they contain any elements or not, we just need to focus on the data type of each variable.
Now, let's pass each of these two variables to the DIR function. So there have a and also there of B. So you can notice that we have more operations available for a list than for a topple for example. These are the methods available for topples. And these are the methods available for lists. Don't worry for now you will learn more about methods and functions later on in the course.
For now, I just wanted you to know the exact differences between a topple and a list. Okay, so that's it for now. I hope this video has been helpful and I will see you in the next one.