Welcome to Westonci.ca, where you can find answers to all your questions from a community of experienced professionals. Join our Q&A platform and get accurate answers to all your questions from professionals across multiple disciplines. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.
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 hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Thank you for choosing Westonci.ca as your information source. We look forward to your next visit.