Skip to content

Instantly share code, notes, and snippets.

@RenSys
Last active April 22, 2017 01:07
Show Gist options
  • Save RenSys/64e60d5d22c87ff818947f28c032fad0 to your computer and use it in GitHub Desktop.
Save RenSys/64e60d5d22c87ff818947f28c032fad0 to your computer and use it in GitHub Desktop.
Standard - Merge even & uneven lists
from itertools import izip_longest
names = ['Karl','Savannah', 'Harvey', 'Scarlett']
letters = [len(n) for n in names]
print " --- merge even lists ---"
for name, count in izip_longest(names, letters):
print "Name '{0}' has {1} letters".format(name, count)
print " --- merge uneven lists ---"
names.append('lenin')
for name, count in izip_longest(names, letters):
print "Name '{0}' has {1} letters".format(name, count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment