Ejercicio 6a
This commit is contained in:
parent
f0183fa536
commit
5eb6909977
|
@ -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)
|
Loading…
Reference in New Issue