Question: Can someone walk me through this code? 1 We've started a recursive function below called strLength 2 that should take in one string parameter, myStr,
1 We've started a recursive function below called strLength 2 that should take in one string parameter, myStr, and #returns its length. However, you may not use Python's 4 built-in len function. 6|#7inish our code. We are missing the base case and the 7| #recursive call. 9 #Hint: Often when we have recursion involving strings, we 10 want to break down the string to be in its simplest form. 11 #7hink about how you could splice a string little by little. 12 Then think about what your base case might be -what is 13 #the most basic, minimal string you can have in python? 14 # 15 #Hint 2: How can you establish the base case has been 16#reached without the len() function? 17 1You may not use the built-in , len()' function. 19 20 def strLength (myStr): 21 if myStrComplete this linel return 0 complete this line! 23 24 25 26 27 #The line below will test your function. As written, this 28 #8hould print 13. You may modifythis to test your code. 29 print (strlength( "13 characters)) 30 31 else: return strLength(myStrll:]) +1WCompulete this linel
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
