Created
January 7, 2014 15:53
-
-
Save shiumachi/8301406 to your computer and use it in GitHub Desktop.
文字列のリストを与えたとき、要素内の最大長の文字列に合わせて右寄せで出力する
This file contains hidden or 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
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