There are three types of sequences in Python:
Lists
One of Python’s most powerful data structures is the list. Lists are a type of sequenced data. Python’s list() method can be used to construct an empty list. They resemble specified arrays in other languages exactly. The fact that the list does not have to be uniform is what makes it so effective. Lists are also mutable, which means you can add, remove or change items in a list after it is created. For example, you can use the append()
method to add an item to the end of a list, the insert()
method to insert an item at a specific index, and the remove()
method to remove an item from a list.
Example of Lists
Tuples
A series of immutable Python objects is known as a tuple. The only difference between tuples and lists is that once declared, tuples cannot be modified. Typically, tuples are quicker than lists.
Example of Tuples
Strings
A string is a group of characters that may include letters, numbers, and special characters in any combination. In Python, it can be stated using single, double, or even triple quotations. Strings cannot be changed since they are immutable. Indexing or slicing techniques can be used to access each element of the string.
Example of String