Python Forum
Problema función listas y diccionarios
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problema función listas y diccionarios
#1
Good afternoon, I'm stuck because I do not know how to tackle the next task, someone could give me a hand on how to approach it
thank you

issue

If we have a dictionary that contains as keys the name of a person and as a value a list with their "personal preferences" that can be, for example "swim", "read", "go to the movies", etc. You want to program a function AddPreference (dictionary, person, preference) such that:
o If the person does not exist, add it to the dictionary with a list that contains only one element.
o If the person exists and the current preference exists on your list, it has no effect, but if that preference does not exist on your list, add it to the list.
Once the above is completed, make a program that adds information to the dictionary and once it has that information included, ask the user for a preference by keyboard and list on the screen the name of all the people who have that preference.
Reply


Messages In This Thread
Problema función listas y diccionarios - by PaulinaJara - Dec-15-2018, 05:17 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020