From 4fab27a9b05814e76f521db459e21bf6074a7461 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 14 Feb 2021 18:46:45 -0500 Subject: [PATCH] Solve 6.5.3 --- 6/6.5/6.5.3/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 6/6.5/6.5.3/main.py diff --git a/6/6.5/6.5.3/main.py b/6/6.5/6.5.3/main.py new file mode 100644 index 0000000..b3c9968 --- /dev/null +++ b/6/6.5/6.5.3/main.py @@ -0,0 +1,20 @@ +user_input= input() +lines = user_input.split(',') + +# This line uses a construct called a list comprehension, introduced elsewhere, +# to convert the input string into a two-dimensional list. +# Ex: 1 2, 2 4 is converted to [ [1, 2], [2, 4] ] + +mult_table = [[int(num) for num in line.split()] for line in lines] + +def print_array(array): + result = [] + for row in array: + result = [] + for column in row: + result.append(column) + result.append('|') + result.pop() + print(*result) + +print_array(mult_table)