Question: I have this Loop code using the Main method as shown. How canit be converted into using constants and declaringcontinue_processing = True . We are

I have this Loop code using the "Main" method as shown. How canit be converted into using constants and declaring"continue_processing = True" . We are not allowed to use the "main"method for now. Thanks!!!

Provided the code and an example below:

Code to fix

# main method def main(): # using infinite while loop to continuously

example of loop we normally use

prompt the user for inputs while True: choice int(input("Enter 1. Encode 2.Decode

# main method def main(): # using infinite while loop to continuously prompt the user for inputs while True: choice int(input("Enter 1. Encode 2.Decode 3. Exit :")) # reading inputs from the user. if choice == 1: text = input('Enter Text:') #reading text from the user = res = encode(text) # calling encode method print('Encoded string is', res) # printing the message returned by the encode method elif choice == 2: text = input('Enter Text:') #reading text from the user res = decode(text) # calling encode method print('Decoded string is', res) # printing the message returned by the decode method elif choice == 3: exit(0) # exiting the program if the choice is 3. else: pass main() # invoking main()

Step by Step Solution

3.50 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Python version 36 Python program to update the given code by removing the main function and using the control variable for the loop Assuming the funct... 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 Electrical Engineering Questions!