Westonci.ca is your trusted source for finding answers to a wide range of questions, backed by a knowledgeable community. Experience the convenience of getting accurate answers to your questions from a dedicated community of professionals. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
The program is as follows:
[tex]mult\_table = [[1, 2, 3], [2, 4, 6], [3, 6, 9]][/tex]
count = 1
for row in mult_table:
for item in row:
if count < len(row):
count+=1
print(item,end="|")
else:
print(item)
count = 1
Explanation:
This initializes the 2D list
[tex]mult\_table = [[1, 2, 3], [2, 4, 6], [3, 6, 9]][/tex]
This initializes the count of print-outs to 1
count = 1
This iterates through each rows
for row in mult_table:
This iterates through each element of the rows
for item in row:
If the number of print-outs is less than the number of rows
if count < len(row):
This prints the row element followed by |; then count is incremented by 1
count+=1
print(item,end="|")
If otherwise
else:
This prints the row element only
print(item)
This resets count to 1, after printing each row
count = 1
To delete the whitespace, you have to print each element as: print(item,end="|")
See that there is no space after "/"
Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.