Answered step by step
Verified Expert Solution
Question
1 Approved Answer
finish recursive python3 program? the program uses a recursive function to scramble a string and print out all of the possibilities. The question marks indicates
finish recursive python3 program?
the program uses a recursive function to scramble a string and print out all of the possibilities. The question marks indicates places where the code needs to be finished. Comments should help with what needs to be there. Sample output is shown.
def scramble(currentScramble, lettersLeft): # base case if ??? # prints out print(???) variable to see result # recursive case else: # for each letter available for scramble for i in range(len lettersLeft)): letter lettersLeftli] # creates a copy of the string without that letter while 1 TenC1ettersLeft): newlettersLeft lettersLeftil + lettersLefti+1:7 # set past the end of string to exit loop = len(letterseft) # add letter removed from lettersLeft to current scrambled word newScramble-2?? # recursive call def mainQ: print("Welcome to scrambler!") word inputC" Please enter a string to scramble:") # call recursive function. scramble() takes in currentScramble, lettersLeft print("Thank you for using the scrambler!n") main) def scramble(currentScramble, lettersLeft): # base case if ??? # prints out print(???) variable to see result # recursive case else: # for each letter available for scramble for i in range(len lettersLeft)): letter lettersLeftli] # creates a copy of the string without that letter while 1 TenC1ettersLeft): newlettersLeft lettersLeftil + lettersLefti+1:7 # set past the end of string to exit loop = len(letterseft) # add letter removed from lettersLeft to current scrambled word newScramble-2?? # recursive call def mainQ: print("Welcome to scrambler!") word inputC" Please enter a string to scramble:") # call recursive function. scramble() takes in currentScramble, lettersLeft print("Thank you for using the scrambler!n") main)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started