Last active
April 22, 2017 01:07
-
-
Save RenSys/64e60d5d22c87ff818947f28c032fad0 to your computer and use it in GitHub Desktop.
Standard - Merge even & uneven lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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