Write a function print contents(data table) that takes a nested list of data and prints its contents as specified below. Notes: • data table is a list of lists with any number of rows or columns. • For each row, print "Row (row_number) contents:" where (row number) is the row's number (starting from 0). • For each column within a row, print - Column (column_number): (contents of column)" where (column_number) is the column's number (starting from 0) and (contents of_column) is the data contained within that column of that row. Note the single space at the start. For example: Test Result two_by_four - [1, 2], [3, 4], [5, 6), [7, 8] Row e contents: Column e: 1 Column 1: 2 Row 1 contents: Column e: 3 Column 1: 4 Row 2 contents: Column e: 5 Column 1: 6 print_contents(two_by_four) Row 3 contents: Column e: 7 Column 1: 8 Row e contents: magic_square- [2, 7, 6], [9, 5, 1], [4, 3, 8] Column e: 2 Column 1: 7 Column 2: 6 Row 1 contents: print contents(magic_square) Column e: 9 Column 1: 5 Column 2: 1 Row 2 contents: Column e: 4 Column 1: 3 Column 2: 8
Write a function print contents(data table) that takes a nested list of data and prints its contents as specified below. Notes: • data table is a list of lists with any number of rows or columns. • For each row, print "Row (row_number) contents:" where (row number) is the row's number (starting from 0). • For each column within a row, print - Column (column_number): (contents of column)" where (column_number) is the column's number (starting from 0) and (contents of_column) is the data contained within that column of that row. Note the single space at the start. For example: Test Result two_by_four - [1, 2], [3, 4], [5, 6), [7, 8] Row e contents: Column e: 1 Column 1: 2 Row 1 contents: Column e: 3 Column 1: 4 Row 2 contents: Column e: 5 Column 1: 6 print_contents(two_by_four) Row 3 contents: Column e: 7 Column 1: 8 Row e contents: magic_square- [2, 7, 6], [9, 5, 1], [4, 3, 8] Column e: 2 Column 1: 7 Column 2: 6 Row 1 contents: print contents(magic_square) Column e: 9 Column 1: 5 Column 2: 1 Row 2 contents: Column e: 4 Column 1: 3 Column 2: 8
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 10E
Related questions
Question
What I've done so far but seems wrong.
row_number=0
column_number=0
for i in range(len(data_table)):
print(f"Row {row_number} contents:")
row_number += 1
for j in range(0, len(data_table[i])):
column_number += 1
print(f" Column {j}: {column_number} ")
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr