Skip to content

Instantly share code, notes, and snippets.

@accessnash
Created June 13, 2018 23:37
Show Gist options
  • Select an option

  • Save accessnash/65a2f0f97d98d26c12e6bfec127b6f88 to your computer and use it in GitHub Desktop.

Select an option

Save accessnash/65a2f0f97d98d26c12e6bfec127b6f88 to your computer and use it in GitHub Desktop.
A function to split names and keep only title and last names
Personalities = ['Mr. Clarke Kent', 'Dr. Victor Doom', 'Dr. Stephen Strange', 'Dr. Jonathan Osterman']
def split_names(superhero):
title = superhero.split()[0]
lastname = superhero.split()[-1]
return '{} {}'.format(title, lastname)
list(map(split_names, Personalities))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment