Question

python

Function Name: find_me Parameters: a dictionary of strings mapping to strings ( dict ), person1 ( str), person2 (str) ReturnsTest Cases V >>> people = {Damian: Jakob, Rajit: Jasmine Y., Jasmine Y.: Arvin, Caitlin: Cathy, Jakob: Cai

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def find_me(people, person1, person2):
    if person1 == person2:
        return 0
    else:
        count = 0
        if person1 not in people:
            return None
        while people[person1] != person2:
            person1 = people[person1]
            if person1 not in people:
                return None
            count += 1
        return count


# Testing the function here. ignore/remove the code below if not required
people = {"Damian": "Jakob", "Rajit": "Jasmine Y.", "Jasmine Y.": "Arvin", "Caitlin": "Cathy", "Jakob": "Caitlin"}
person1 = "Damian"
person2 = "Cathy"
print(find_me(people, person1, person2))

people = {"Arushi": "Juliette", "Brae": "Arushi", "Anthony": "Jasmine C."}
person1 = "Brae"
person2 = "Jasmine C."
print(find_me(people, person1, person2))

None Process finished with exit code 0

Add a comment
Know the answer?
Add Answer to:
python Function Name: find_me Parameters: a dictionary of strings mapping to strings ( dict ), person1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT