Ejercicio 6a

This commit is contained in:
perro tuerto 2023-03-06 12:21:02 -08:00
parent f0183fa536
commit 5eb6909977
2 changed files with 20 additions and 0 deletions

20
exercises/ex06/ex06a.py Normal file
View File

@ -0,0 +1,20 @@
tableData = [
["apples", "oranges", "cherries", "banana"],
["Alice", "Bob", "Carol", "David"],
["dogs", "cats", "moose", "goose"],
]
def printTable(table):
msg = ""
for i, row in enumerate(table):
width = list(sorted(map(lambda x: len(x), row)))[-1] + 1
table[i] = list(map(lambda y: y.rjust(width), row))
for i in range(0, len(table[0])):
for j in range(0, len(table)):
msg += table[j][i]
msg += "\n"
print(msg.rstrip())
printTable(tableData)

0
exercises/ex06/ex06b.py Normal file
View File