Exercise 1: Introduction to Sets
Welcome to Python 2, Lesson 4! Today, we'll learn about sets, another useful data structure in Python.
What is a Set?
A set is an unordered collection of unique elements. This means that each item in a set appears only once, and the order doesn't matter.
Here's how to create a simple set:
Now it's your turn! Create a set called colors with the following items:
- red
- green
- blue
- red (yes, add it twice!)
After creating the set, print it and its type to see the result. Notice how duplicates are automatically removed!
# Create the colors set here
# Print the set and its type