Search code examples
pythonvariablesdictionarydata-structuresstandards

Python data structure like dict


Online I found some code that used the variable explored. This variable is implemented like a dictionary: explored = {rootId}, but it doesn't have key-value association, moreover this variabile uses the function .add(elem) while the dict doesn't have this function. eg. explored.add(elem).

Which data structure is that? (I'm using python 3.6.3)


Solution

  • It's a set. There are also online examples that use the methods you mentioned.

    Next time you wonder, I suggest you just print the type, like this:

    print(type(explored));