Skip to content

Instantly share code, notes, and snippets.

@leleofg
Created January 31, 2018 16:19
Show Gist options
  • Select an option

  • Save leleofg/3f62b4d52a22cb507b67f8a9f32e346a to your computer and use it in GitHub Desktop.

Select an option

Save leleofg/3f62b4d52a22cb507b67f8a9f32e346a to your computer and use it in GitHub Desktop.
Example Map function
people = ['Dr. Christopher Brooks', 'Dr. Kevyn Collins-Thompson', 'Dr. VG Vinod Vydiswaran', 'Dr. Daniel Romero']
def split_title_and_name(person):
title = person.split()[0]
lastname = person.split()[-1]
return '{} {}'.format(title, lastname)
list(map(split_title_and_name, people))
#['Dr. Brooks', 'Dr. Collins-Thompson', 'Dr. Vydiswaran', 'Dr. Romero']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment