0

Hi I am troubling with this problem and I want to flatten a nested list. Here is my code but it does not work can someone help me please

def paps(lst):
    if lst == []:
        return lst
    if type(lst[0]) == list:
        return paps(lst[0])+ paps(lst[1:])
    else:
        return lst[:1] + paps(lst[1:])

My problem must be with recursion.

AChampion
  • 29,683
  • 4
  • 59
  • 75

0 Answers0