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

1014 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs


What is the difference between a cycle "if" and "while"?


What are docstrings and how do I use them to improve my code readability?


Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


We're here to help

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

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy