Answer to Question #257845 in Python for Alhaji

Question #257845

Unit 7 Submission


# name : [animal type, age, sex]

animal_shellter = {

 "rocky": ["dog",2,"male"],

 "judy": ["dog",2,"female"],

 "Malisa": ["dog",8,"female"],

 "Punk": ["hamster",7,"male"],

 "Kendy": ["cat",12,"male"],

 "Monalisa": ["cat",5,"female"],

}


print(animal_shellter)

print("")


def invert(d):

 inverse = dict()

 for key in d:

  val = d[key]

  for item in val:

   if item not in inverse:

    inverse[item] = [key]

   else:

    inverse[item].append(key)

 return inverse 


inverted_shellter = invert(animal_shellter)

print(inverted_shellter)


1
Expert's answer
2021-10-28T01:30:21-0400
Dear Alhaji, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog