Skip to content

Instantly share code, notes, and snippets.

@mattroyer
Last active May 10, 2016 21:43
Show Gist options
  • Save mattroyer/23bf246af5e703453b8efd6f50ea1d2f to your computer and use it in GitHub Desktop.
Save mattroyer/23bf246af5e703453b8efd6f50ea1d2f to your computer and use it in GitHub Desktop.
Zip Lists Together
families = [["Jenny", "Dana", "Tana", "Shawn", "Mark"], ["Kevin", "Jamison", "Brian", "Alice"], ["Chris", "John", "April"], ["Kevin", "Jim", "Bobby", "Ryan"]]
surnames = ['Richards', 'Millhouse', 'Carmichael', 'Williams']
for index, name in enumerate(surnames):
families[index] = list(map(lambda x: "%s %s" % (x, name), families[index]))
for family in families:
print(family)
#=> ['Jenny Richards', 'Dana Richards', 'Tana Richards', 'Shawn Richards', 'Mark Richards']
# ['Kevin Millhouse', 'Jamison Millhouse', 'Brian Millhouse', 'Alice Millhouse']
# ['Chris Carmichael', 'John Carmichael', 'April Carmichael']
# ['Kevin Williams', 'Jim Williams', 'Bobby Williams', 'Ryan Williams']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment