Guest User

Untitled

a guest
May 7th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. # Create sort_contacts function
  2. def sort_contacts(contact_import):
  3. result = []
  4.  
  5.  
  6.  
  7. for contact in sorted(contact_import.keys()):
  8. #contact_import[contact]
  9.  
  10. new_list = list(contact_import[contact])
  11.  
  12. #x = new_list.pop()
  13.  
  14. tuple_list = tuple([contact] + new_list)
  15.  
  16. result.append(tuple_list)
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. print(result)
  25. return result
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. # The code below is just for your testing purposes. Make sure you pass all the tests.
  33. from test import testEqual
  34.  
  35. testEqual(sort_contacts({"Horney, Karen": ("1-541-656-3010", "karen@psychoanalysis.com"),
  36. "Welles, Orson": ("1-312-720-8888", "orson@notlive.com"),
  37. "Freud, Anna": ("1-541-754-3010", "anna@psychoanalysis.com")}), [('Freud, Anna', '1-541-754-3010',
  38. 'anna@psychoanalysis.com'), ('Horney, Karen', '1-541-656-3010', 'karen@psychoanalysis.com'),
  39. ('Welles, Orson', '1-312-720-8888', 'orson@notlive.com')])
  40. testEqual(sort_contacts({"Summitt, Pat": ("1-865-355-4320", "pat@greatcoaches.com"),
  41. "Rudolph, Wilma": ("1-410-5313-584", "wilma@olympians.com")}),
  42. [('Rudolph, Wilma', '1-410-5313-584', 'wilma@olympians.com'),
  43. ('Summitt, Pat', '1-865-355-4320', 'pat@greatcoaches.com')])
  44. testEqual(sort_contacts({"Dinesen, Isak": ("1-718-939-2548", "isak@storytellers.com")}),
  45. [('Dinesen, Isak', '1-718-939-2548', 'isak@storytellers.com')])
  46. testEqual(sort_contacts({"Rimbaud, Arthur": ("1-636-555-5555", "arthur@notlive.com"),
  47. "Swinton, Tilda": ("1-917-222-2222", "tilda@greatActors.com"),
  48. "Almodovar, Pedro": ("1-990-622-3892", "pedro@filmbuffs.com"), "Kandinsky, Wassily":
  49. ("1-333-555-9999", "kandinsky@painters.com")}), [('Almodovar, Pedro', '1-990-622-3892',
  50. 'pedro@filmbuffs.com'), ('Kandinsky, Wassily', '1-333-555-9999', 'kandinsky@painters.com'),
  51. ('Rimbaud, Arthur', '1-636-555-5555', 'arthur@notlive.com'), ('Swinton, Tilda',
  52. '1-917-222-2222', 'tilda@greatActors.com')])
Add Comment
Please, Sign In to add comment