Question: Generate a Python user-defined function that accepts a string and a number 'n' representing a shift index and encrypts the string by substituting (ciphering)
Generate a Python user-defined function that accepts a string and a number 'n' representing a shift index and encrypts the string by substituting (ciphering) each alphabetic letter by increasing it by n (wrapping around to the beginning of the alphabet when required). The function prototype MUST be: def charShifter (userString, n) For example, if the string was: "abc-xyz", and the shift value was: 3, then the function call: charShifter("abc-xyz", 3) would display and return the encrypted string: "def-abc"
Step by Step Solution
There are 3 Steps involved in it
python def charShifteruserString n encryptedstring for char in userString if charisalpha isupper cha... View full answer
Get step-by-step solutions from verified subject matter experts
