Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
example of loop we normally use
# 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
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started