xYjoeYx
xYjoeYx

Reputation: 21

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)

Upvotes: 1

Views: 96

Answers (3)

Aleksei Maide
Aleksei Maide

Reputation: 1855

Might be a set, it has a method "add", but you could simply print the type, such as:

print(type(explored))

Upvotes: 3

gsamaras
gsamaras

Reputation: 73366

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));

Upvotes: 2

Gábor Fekete
Gábor Fekete

Reputation: 1358

It's the set datastructure. Here's a link to it on the official docs: https://docs.python.org/3/tutorial/datastructures.html#sets

Upvotes: 0

Related Questions