-
Notifications
You must be signed in to change notification settings - Fork 9
Lecture "Organising information: unordered structures", exercise 3 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
my_dict = dict() |
set_hobbit = {"Frodo", "Sam", "Pippin", "Merry"} |
set_hobbit = {"Frodo", "Sam", "Pippin", "Merry"} lotr_dict = {"hobbits": set_hobbit, "magicians": set_magician} |
result: |
Another solution may be:
|
|
''' tlor_dict["magician"] = {"Saruman", "Gandalf"} print (tlor_dict) #the dictionary will be: ''' |
|
|
|
|
Input
Output
|
Output
|
|
Suppose to organise some of the elements in the set returned by the second exercise in two different sets:
set_hobbit
that refers to the setset({"Frodo", "Sam", "Pippin", "Merry"})
, andset_magician
defined asset({"Saruman", "Gandalf"})
. Create a dictionary containing two pairs: one that associates the set of hobbits with the key"hobbit"
, and the other that associates the set of magicians with the key"magician"
.The text was updated successfully, but these errors were encountered: