Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python The Second Property: No Duplicates

Edward Citalan
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Edward Citalan
Python Development Techdegree Graduate 11,397 Points

How does python know if it is an empty set vs. a dictionary?

For example, if one is iterating using a for-loop, how would python know given that the syntax is similar: set = {} vs dict = {}? Is it because one is a sequence while the other is not?

1 Answer

Steven Parker
Steven Parker
231,269 Points

While you can create a literal set with braces, the symbols "{}" represent an empty dictionary.

If you want to create an empty set, use myset = set() instead.