I want to use sets as data structure. how should i make it possible?
what are the commands I need?
Like closedset = set()
is this ok?
And in a set, if i want to get some value out, what is the command for that one?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Correct. To create an empty set, write
foo = set(). To retrieve values, you can iterate over the set:You can also write
val in somesetto check if an item is in a set.Be sure to read the documentation for how to do set operations.