Question: THIS IS THE REFERENCE QUESTION AND CODE I WROTE: Let's continue the process! Make functionatbash_encrypt()that takes a string as its input and returns the reverse
THIS IS THE REFERENCE QUESTION AND CODE I WROTE:
Let's continue the process!
Make functionatbash_encrypt()that takes a string as its input and returns the reverse alphabetical string as its output (the same task as Q2...just turning it into a function).
Remember that functions have their own namespace, so you'll likely want to redefinealphaandreverse_alphain your function directly.
def atbash_encrypt(input_string):
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
reverse_alpha = 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
#creating a reverse string
reverse_string= ""
#looping through all characters in the input string
for char in input_string:
if char.upper() in alpha:
index= alpha.find(char.upper())
reverse_string += reverse_alpha[index]
else:
#if the upper case of any character is not in alpha, return None
return None
return reverse_string
THIS IS THE QUESTION AT HAND:
Make test functiontest_atbash_encrypt()that:
- contains at least three asserts that test the functionality ofatbash_encrypt()
- passes silently when executed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
