Hi I was wondering if someone could help me to figure out how to write a code for :
Write a function print_table which consumes two parameters, a list of list of strings,
and an integer for the length of the list. The function should print out the strings from
each sublist on each line. Commas and spaces are used to separate strings on the same
line. If the list is empty, then an empty string will be printed out. You may use the
above defined function print_row as helper function.
As an example, if the input list is defined as [[”Jack”, ”Smith”, ”CS”, ”ON”], [”
Alice”, ”Adam”, ”Math”, ”SK”], [”Jean”, ”Guy”, ”PHY”, ”QC”], [”Kim”, ”King
”, ”ENGL”, ”NS”]], the function should have the following printed out,
Jack, Smith, CS, ON
Alice, Adam, Math, SK
Jean, Guy, PHY, QC
Kim, King, ENGL, NS
I did manage to write the code for the print_row function:
def print_row(row):
x= ' '
print helper(row,x)
def helper(l,s):
if len(l) > 1 :
s = s + l[0] + ', '
return helper(l[1:],s)
else:
return s + l[0]
oh, and we are suppose to use lambda, and abstract list functions if we can. thanks, ^^