SNHU-IT-140/6/6.5/6.5.3/main.py

21 lines
553 B
Python

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)