01 / 06
What happens if you drop the colon
Last lesson you learned that braces { } with key: value give you a dictionary.
So what happens if you drop the colon and write only the value? What you get is a set, a different container again.
The headline property of a set is that anything turning up twice is folded into one. In the example below "red" appears twice, and the contents come to three.
words = ["red", "blue", "red", "yellow"]colours = {w for w in words}print(len(colours))Result
3