Answer:
Advantages and disadvantages of tuple and list;
You can't add elements to a tuple. Tuples have no append or extend method.You can't remove elements from a tuple.
Tuples have no remove or pop method.You can find elements in a tuple, since this doesn’t change the tuple.You can also use the in operator to check if an element exists in the tuple.
Tuples are faster than lists. If you're defining a constant set of values and all you're ever going to do with it is iterate through it, use a tuple instead of a list.It makes your code safer if you write-protect data that does not need to be changed.
Using a tuple instead of a list is like having an implied assert statement that this data is constant, and that special thought (and a specific function) is required to override that.Some tuples can be used as dictionary keys (specifically, tuples that contain immutable values like strings, numbers, and other tuples). Lists can never be used as dictionary keys, because lists are not immutable.
Below I have given the difference between list and tuple
Literal
someTuple = (1,2)
someList = [1,2]
Size
x = tuple(range(1000))
y = list(range(1000))
x.__sizeof__() # 8024
y.__sizeof__() # 9088
Due to the smaller size of a tuple operation, it becomes a bit faster, but not that much to mention about until you have a huge number of elements.
Permitted operations
y = [1,2]
y[0] = 3 # [3, 2]
x = (1,2)
x[0] = 3 # Error
That also means that you can't delete an element or sort a tuple. However, you could add a new element to both list and tuple with the only difference that since the tuple is immutable, you are not really adding an element but you are creating a new tuple, so the id of will change
x = (1,2)
y = [1,2]
id(x) # 140230916716520
id(y) # 748527696
x += (3,) # (1, 2, 3)
y += [3] # [1, 2, 3]
id(x) # 140230916878160
id(y) # 748527696
Usage
As a list is mutable, it can't be used as a key in a dictionary, whereas a tuple can be used.
x = (1,2)
y = [1,2]
z = {x: 1} # OK
z = {y: 1} # Error
Hope you understand this if you can not ask me anything you want to know about this