Question
Asked Nov 1, 2019
24 views

Given a nested list named table, use a loop to print each sub list of the nested list. The sub lists should be on their own line. 

This is for python 

check_circle

Expert Answer

Step 1

Program description

  • One 3 x3 list is created to demonstrate the concept
  • display the elements of the sublists in the same line
  • two for loops are used to print the sublists
  • special print command option used to enable printing all elements of a sublist in the same line
Step 2

Python Program

#3 by 3 list

table =[[10,9,8],[7,6,5],[4,3,2]]

#find the length of the list

length = len(table)

i = 0

#iterate over the elements of the list to print

#the elements all sub list elements in the same line

for a in table:

    l = len(a)

    for i in range(l):

        print(a[i],end =' ')

    print(' ')

Step 3

Program image

...
help_outline

Image Transcriptionclose

#3 by 3 List 2 table -[[10,9, 8], [7,6,5], [4,3,2]] #find the length of the list 4 length = len (table ) i - e 6 #iterate over the elements of the list to print #the elements all sub list el ements in the same Line for a in table: 1 - len(a) for i in range(1) : 1 3 5 7 10 print(a[i],end 11 print ' 12

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Python 3.7.4 Write a statement to open the file priceList.txt for writing.

A: To open the file priceList.txt for writing, the statement is: f=open('priceList.txt','w')The followi...

question_answer

Q: This is for python

A: The expression would be:dow[len(dow)-2] The program is following:dow = "help!"print(dow[len(dow)-2])

question_answer

Q: What is the difference between hardware interrupts and software interrupts and give examples of situ...

A: Hardware interrupts:The physical signals either from within the microcontroller itself or may be fro...

question_answer

Q: Create 10 echo statements introducing yourself, your major , your favorite color , your dream vacati...

A: The echo statement is used in PHP to print the data to the output screen.echo statement has no retur...

question_answer

Q: You are asked to write a simple C program that will accept an integer value in the range of 5-95 wit...

A: Each functionality defined in relatively small number of functions to one function that can be reuse...

question_answer

Q: Consider partitioning the list {1,4,0,1,1,1,2,3,1,0,4,4,1,2,0,1} where the first element ofthe array...

A: Program description for part (A)The program for part A works by using two new arrays for the left an...

question_answer

Q: Is there anything wrong with my code? If so, explain and provide a remedy.     int SIZE = 25;     do...

A: Note:The given code is executed in C++. If you wants this program code to be executed and cleared wi...

question_answer

Q: So the programming language for this problem is python.  How do I create a function that allows the ...

A: In this python program, The user is asked to enter an array of integers. First index of this array r...

question_answer

Q: You are given a function called is_prime  which consumes a positive number and returns True if the n...

A: Before solving this question first, you should know some functions definitions :Prime number: Primar...