Use recursion to print all the sublists of a given list

def withoutIndex (lst, i): return lst[ : i] + lst[i + 1 : ]def printSublists(lst): print(lst) for i in range(len(lst)): printSublists(withoutIndex(lst, i))printSublists([1, 2, 3])

Answered by Nikolai M. Python tutor

1360 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do I use for loops in Python?


What does __init__ mean?


Give an example of a FOR loop


Write a function that takes a list of numbers as input, and outputs the average of the numbers. The function should catch any errors.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo
Cookie Preferences