Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help with this following Python problem.. Thank you in advance! In the cell below, there is a function that is not operating

Hello, I need help with this following Python problem.. Thank you in advance!

image text in transcribed
In the cell below, there is a function that is not operating as anticipated. new_encrypt is supposed to take a string as input and return the reverse alphabetical string as output, meaning, given a character, return the capitalized character in the reverse position within the alphabet. For example, if the input character is 'B' or 'b', the function would store 'Y' in the output string. If the character is 'A' or 'a', the function would store '2'. (and vice versa: the input '2' or '2' would store 'A'). Specifically, if the input_string were "ABc", the function would return : 'ZYX' Debug, edit, and test the function provided below so that it accomplishes the intended goal. 1 def new_encrypt( ) : 2 alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 3 reverse_alpha = 'ZYXWVUTSRQPONMLKJIHGFEDCBA' 4 5 for char in input_string: 6 if char in alpha: 7 position = alpha.find(char) 8 output_string += reverse_alpha[position] 9 else: 10 output_string = None 11 break 12 13 # YOUR CODE HERE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions