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

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

1 Expert Approved Answer
Step: 1 Unlock

python def charShifteruserString n encryptedstring for char in userString if charisalpha isupper cha... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!