Professional Documents
Culture Documents
List Tuples Set Dict
List Tuples Set Dict
List Tuples Set Dict
For example:
Lists
• More on Slicing
Lists
• Modifying Elements in a List:
You can modify an element in a list by assigning a new value to it using
its index. For example:
Lists
• Adding Elements to a List:
You can add elements to a list using the append() method. For example:
Lists
• Removing Elements from a List:
You can remove elements from a list using the remove() method. For
example:
Tuples
• A tuple is a collection of elements enclosed in parentheses and
separated by commas.
• Tuples are similar to lists, but they are immutable, which means you
cannot modify their contents after they have been created.
• You can also create a set using the set() function and passing a list,
tuple or any other iterable object as an argument:
Set
• Sets do not allow duplicate elements, so any duplicate elements in the
input are automatically removed when creating a set. Here's an
example:
Set
• Adding elements to Set: