Write a Python function called print_nested_list that takes a single parameter, a list of lists of strings. Complete the function as follows: Each list of strings should be printed with a single space between each string, all on the same line Each list of strings should be printed on its own line Your code shouldn't return a value. For example, the list [["Test"], ["Example", "Online"] should print: Test Example Online

Respuesta :

Answer:

def print_nested_list(lst):

  for sub_list in lst:

      print(*sub_list)

lst = [["Test"], ["Example", "Online"]]

print_nested_list(lst)

Explanation:

Create a function named print_nested_list that takes one parameter, lst

Inside the function, create a for loop that iterates through the lst

Inside the for loop, print each sublist by using print(*sub_list)

(*sub_list allows us to unpack the lst so that we will be able to reach each sublist inside the lst)

Call the function to test with a nested list

fichoh

The program displays each element in a list of list as a string seperated by a space. The program written in python 3 goes thus :

def print_nested_list(liist):

#initialize a function which takes in a single parameter

for sub_list in liist:

#iterate through each element in the list of list

print(*sub_list, end=' ')

#print each element in the lists with the cursor remaining on the same line.

liist = [["Test"], ["Example", "Online"]]

#samole run of program

print_nested_list(liist)

#display

Learn more : https://brainly.com/question/20533392

Ver imagen fichoh
ACCESS MORE