Previous Lesson Current Lesson Next Lesson

Question 1

t = (5, "dog", 5)
s = set(t)

Converting from tuple to set is essentially the same as what we saw with converting list to set: just pass the tuple into the __init__ method for set.

Question 2

Building off of our previous solution, we have:

t = (5, "dog", 5)
s = set(t)


This will output:


s has fewer elements because of the duplicate 5.

Question 3

l = [5, "dog", 5]
t = tuple(l)

Just pass the list into the __init__ method for tuple, and done!