Skip to content

Instantly share code, notes, and snippets.

@shiumachi shiumachi/align.py
Created Nov 29, 2018

Embed
What would you like to do?
def print_arr_right_aligned(arr):
""" input: string array ['a', 'ab', 'abc']
output: None. print with right aligned.
a:
ab:
abc:
"""
len_a = max(map(lambda x: len(x), arr))
for i in arr:
print("{0:>{1}}: ".format(i, len_a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.