Question: PYTHON Print the two-dimensional list mult_table by row and column. On each line, each character is separated by a space. Hint: Use nested loops. Sample

PYTHON

Print the two-dimensional list mult_table by row and column. On each line, each character is separated by a space. Hint: Use nested loops. Sample output with input: '1 2 3,2 4 6,3 6 9':

1 | 2 | 3 2 | 4 | 6 3 | 6 | 9

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]

''' Your solution goes here ''' for lst in mult_table: for i in range(len(lst)): print(lst[i], end='') if i != len(lst)-1: print(' | ',end='') print()

testing with input: '1 2 3,2 4 6,3 6 9'

Output is nearly correct; but whitespace differs. See highlights below. Special character legend

Your output

1 | 2 | 32 | 4 | 63 | 6 | 9

Expected output

1 | 2 | 3 2 | 4 | 6 3 | 6 | 9

clearTesting with input: '1 2 3 4,2 4 6 8,3 6 9 12,4 8 12 16'

Output is nearly correct; but whitespace differs. See highlights below. Special character legend

Your output

1 | 2 | 3 | 42 | 4 | 6 | 83 | 6 | 9 | 124 | 8 | 12 | 16

Expected output

1 | 2 | 3 | 4 2 | 4 | 6 | 8 3 | 6 | 9 | 12 4 | 8 | 12 | 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!