Westonci.ca is your go-to source for answers, with a community ready to provide accurate and timely information. Get immediate and reliable solutions to your questions from a knowledgeable community of professionals on our platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.
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 "/"
We appreciate your visit. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.