Question: Help with this function please. Thank you! 2. Write a function encipher (s,n) that takes as inputs an arbitrary string s and a non-negative integer
Help with this function please. Thank you!
2. Write a function encipher (s,n) that takes as inputs an arbitrary string s and a non-negative integer n between 0 and 25, and that uses recursion to create and return a new string in which the letters in s have been "rotated" by n characters forward in the alphabet, wrapping around as needed. Upper-case letters should be rotated to upper-case letters, lower-case letters should be rotated to lower-case letters, and nonalphabetic characters should be left unchanged. For example: In addition to calling itself recursively, the function must call your rotate function to determine the rotated version of a given character. Doing so will make your enci pher function much easier to write! Once you think you have everything working, here are three more examples to try: encipher ( 'xyza' , 1) result: 'yzab' >>> encipher ('Z A', Z) result: 'B C' > encipher ('Caesar cipher? I prefer Caesar salad.' , 25) result: 'Bzdrzq bhogdq? H oqdedq Bzdrzq rzkzc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
