Created
February 8, 2017 12:47
-
-
Save rougeth/301d862155da380ca930aa3713052085 to your computer and use it in GitHub Desktop.
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 functools import reduce | |
def center(words): | |
max_length = reduce(lambda a, b: a if a > len(b) else len(b), words, 0) | |
words = [word if len(word) == max_length else '{}{}'.format(' ' * ((max_length - len(word)) // 2), word) for word in words] | |
for word in words: print(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment