Solve 6.5.3
This commit is contained in:
20
6/6.5/6.5.3/main.py
Normal file
20
6/6.5/6.5.3/main.py
Normal file
@@ -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)
|
||||||
Reference in New Issue
Block a user