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])

NM
Answered by Nikolai M. Python tutor

1497 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What would output this code? print(hello world)


Write a program that can convert between celcius and farenheit temperature scales


Write a function s(n) that will return a list of the first n squares.


Using the shared code editor, write a recursive function for calculating a factorial of an input parameter.


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences