Implement function get_contact(contacts, name) that returns a string. The contacts and the name parameter are both type...

70.2K

Verified Solution

Question

Programming

Implement function get_contact(contacts, name)that returns a string. The contacts and the name parameter are bothtype string. This function checks for the name string in thecontacts string and returns that person’s contact information. Ifthe person is not found, the function returns, “name not incontact”. Assume input is always valid. Assume the same name is notrepeated in contacts.

[You may use split(), range(), len() ONLY and no other built-infunction or method]


Examples:

              contacts= “Frank 703-222-2222 Sue 703-111-1111 Jane703-333-3333”

              name= “Sue”

              print(get_contact(contacts,name))

              returns:

              703-111-1111

              name= “Sam”

print(get_contact(contacts, name))

              returns:

              namenot in contact

Answer & Explanation Solved by verified expert
4.3 Ratings (821 Votes)
CODE WITHEXPLANATIONdef getcontactcontactsnamefunction definition withrequired parameters conliscontactssplit splits the string with space as    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students