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

1400 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a program that computes the sum of all numbers up to a input number n


What is the difference between & and && operators?


how to compute the factorial of a number.


Write a function that takes an imput (call it usr_in), the user's age (usr_age) and the user's name (usr_nm) and outputs the following string: "Hi, My name is [usr_nm], I am [usr_age] years old, and my favorite number is [usr_in]"


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–2025

Terms & Conditions|Privacy Policy
Cookie Preferences