AutomateTheBoringStuff.Ch06.Projects package

Submodules

AutomateTheBoringStuff.Ch06.Projects.P1_tablePrinter module

Table printer

This program displays a list of strings in a table.

Write a function named print_table() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner lists will contain the same number of strings.

For example, the value could look like this:

tableData = [['apples', 'oranges', 'cherries', 'banana'],
             ['Alice', 'Bob', 'Carol', 'David'],
             ['dogs', 'cats', 'moose', 'goose']]

Your print_table() function would print the following:

  apples Alice  dogs
 oranges   Bob  cats
cherries Carol moose
  banana David goose
AutomateTheBoringStuff.Ch06.Projects.P1_tablePrinter.main()[source]
AutomateTheBoringStuff.Ch06.Projects.P1_tablePrinter.print_table(matrix: list) → None[source]

Print table

Prints given matrix with right justification based on the longest word in each row.

Parameters:matrix – List of lists containing strings.
Returns:None. Prints out matrix as table.

Module contents