Last active
May 28, 2020 10:09
-
-
Save kurzweil777/0f2a2b3ae9e672a7c24826918ba43f6c to your computer and use it in GitHub Desktop.
Automate Boring Stuff with Python
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
"""Задание - https://yapx.ru/v/HV2wK""" | |
def print_table(your_table): | |
col_widths = [0] * len(your_table) | |
for i in range(len(col_widths)): | |
col_widths[i] = max(your_table[i], key=len) | |
for g in range(len(col_widths)): | |
col_widths[g] = len(col_widths[g]) | |
number = max(col_widths) | |
for column1, column2, column3 in zip(*your_table): | |
print(column1.rjust(number) + column2.rjust(number) + column3.rjust(number)) | |
r_table = [['apples', 'oranges', 'cherries', 'banana'], | |
['Alice', 'Bob', 'Carol', 'David'], | |
['dogs', 'cats', 'moose', 'goose']] | |
print_table(r_table) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment