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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
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} ")

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 - [
Row e contents:
[1, 2],
[3, 4],
[5, 6],
Column e: 1
Column 1: 2
Row 1 contents:
[7, 8]
Column e: 3
Column 1: 4
print_contents(two_by_four)
Row 2 contents:
Column e: 5
Column 1: 6
Row 3 contents:
Column e: 7
Column 1: 8
magic_square- (
[2, 7, 6],
[9, 5, 1],
Row e contents:
Column e: 2
Column 1: 7
[4, 3, 8]
Column 2: 6
Row 1 contents:
Column e: 9
print contents (magic_square)
Column 1: 5
Column 2: 1
Row 2 contents:
Column e: 4
Column 1: 3
Column 2: 8
Transcribed Image Text: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 - [ Row e contents: [1, 2], [3, 4], [5, 6], Column e: 1 Column 1: 2 Row 1 contents: [7, 8] Column e: 3 Column 1: 4 print_contents(two_by_four) Row 2 contents: Column e: 5 Column 1: 6 Row 3 contents: Column e: 7 Column 1: 8 magic_square- ( [2, 7, 6], [9, 5, 1], Row e contents: Column e: 2 Column 1: 7 [4, 3, 8] Column 2: 6 Row 1 contents: Column e: 9 print contents (magic_square) Column 1: 5 Column 2: 1 Row 2 contents: Column e: 4 Column 1: 3 Column 2: 8
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Lists
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.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education