Below is the code I typed and I attach two screenshots one with the prompt and the other is the feedback. If possible can someone fix my code base of the feedback or improve the entire code by using mainly loops in Python. Thank you. # Initialize the client list and balance NewClient = [] Balance = [] while True:     print("1- Add a new client")     print("2- Remove a client")     print("3- Insert an item to the list")     print("4- Search for the client based on firstName")     print("5- Search for the client based on lastName")     print("6- Sort the list in descending order (firstName)")     print("7- Quit the program")     option = input("Please enter your option: ")     if option == "1":         client_name = input("Please enter the client's name: ")         balance = float(input("Please enter the client's balance: "))         NewClient.append(client_name)         Balance.append(balance)     elif option == "2":         client_name = input("Please enter the client's name to remove: ")         if client_name in NewClient:             index = NewClient.index(client_name)             NewClient.pop(index)             Balance.pop(index)         else:             print("Client not found in the list.")     elif option == "3":         index = int(input("Where do you want to insert the client? (Enter the index number) "))         client_info = input("Please enter the client info: ")         NewClient.insert(index, client_info)     elif option == "4":         first_name = input("Please enter the first name to search for: ")         for i in range(len(NewClient)):             if first_name in NewClient[i]:                 print("Client found:", NewClient[i])                 print("Balance:", Balance[i])                 break         else:             print("Client not found.")     elif option == "6":         NewClient.sort(reverse=True)     elif option == "7":         break     else:         print("Invalid option. Please choose a valid option.")     # Display the updated list     print("Your original List:")     print("Client=",NewClient)     print("Balance=", Balance) # After the loop ends print("Goodbye!")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Below is the code I typed and I attach two screenshots one with the prompt and the other is the feedback. If possible can someone fix my code base of the feedback or improve the entire code by using mainly loops in Python. Thank you.

# Initialize the client list and balance
NewClient = []
Balance = []

while True:
    print("1- Add a new client")
    print("2- Remove a client")
    print("3- Insert an item to the list")
    print("4- Search for the client based on firstName")
    print("5- Search for the client based on lastName")
    print("6- Sort the list in descending order (firstName)")
    print("7- Quit the program")

    option = input("Please enter your option: ")

    if option == "1":
        client_name = input("Please enter the client's name: ")
        balance = float(input("Please enter the client's balance: "))
        NewClient.append(client_name)
        Balance.append(balance)
    elif option == "2":
        client_name = input("Please enter the client's name to remove: ")
        if client_name in NewClient:
            index = NewClient.index(client_name)
            NewClient.pop(index)
            Balance.pop(index)
        else:
            print("Client not found in the list.")
    elif option == "3":
        index = int(input("Where do you want to insert the client? (Enter the index number) "))
        client_info = input("Please enter the client info: ")
        NewClient.insert(index, client_info)
    elif option == "4":
        first_name = input("Please enter the first name to search for: ")
        for i in range(len(NewClient)):
            if first_name in NewClient[i]:
                print("Client found:", NewClient[i])
                print("Balance:", Balance[i])
                break
        else:
            print("Client not found.")
    elif option == "6":
        NewClient.sort(reverse=True)
    elif option == "7":
        break
    else:
        print("Invalid option. Please choose a valid option.")

    # Display the updated list
    print("Your original List:")
    print("Client=",NewClient)
    print("Balance=", Balance)

# After the loop ends
print("Goodbye!")

Create a menu to allow the banker to add a client, insert the client into a special location in the list, closing the account(remove), find the client based on firstName, and sort the list in
descending order (larger to smaller value).
NewClient=["Mike navarro","Miguel saba","Maria Rami"] Balance= [900.00, 400.00, 450.00]
You may use any of build in functions. Here is an sample output:
1- Add a new client
2- Remove a client
3- Insert an item to the list
4- Search for the client based on firstName
5-Search for the client based on lastName
6- Sort the list in descending order(firstName)
7- Quit the program
Please enter your option: 3
Where do you want to insert the client? (Enter the index number) 1
Please enter the client info: "Tina Mari"
Your original List: ["Mike navarro","Miguel saba","Maria Rami"]
After inserting an item into index 1:
["Mike navarro","Tina Mari", "Miguel saba","Maria Rami"]
Once the user enters an option, your program should execute the code for that option and displays the list before and after the operations. Make sure to use a while loop so the program
runs until user enters the quit option.
Transcribed Image Text:Create a menu to allow the banker to add a client, insert the client into a special location in the list, closing the account(remove), find the client based on firstName, and sort the list in descending order (larger to smaller value). NewClient=["Mike navarro","Miguel saba","Maria Rami"] Balance= [900.00, 400.00, 450.00] You may use any of build in functions. Here is an sample output: 1- Add a new client 2- Remove a client 3- Insert an item to the list 4- Search for the client based on firstName 5-Search for the client based on lastName 6- Sort the list in descending order(firstName) 7- Quit the program Please enter your option: 3 Where do you want to insert the client? (Enter the index number) 1 Please enter the client info: "Tina Mari" Your original List: ["Mike navarro","Miguel saba","Maria Rami"] After inserting an item into index 1: ["Mike navarro","Tina Mari", "Miguel saba","Maria Rami"] Once the user enters an option, your program should execute the code for that option and displays the list before and after the operations. Make sure to use a while loop so the program runs until user enters the quit option.
Probably don't need my input anymore, but...
For Option 3, you don't ask the userto enter in the balance of the new client info. Also, you should be vlaidating user inputs to make sure they are valid before
proceeding with your program, or they might crash it.
For option 6, you forgot to also sort the balance list to ensure the balance data stays paired with proper client name.
AndyNardo Today at 11:17 AM
Smart move on printing to screen the updated lists at the end of the program. I was a dum dum and wrote that same damn statement for each option. What a waste of
script. However! You don't actually print the original List despite printing to screen "Your original List:". In fact, you wouldn't be able to do that at the end of the
program anyways, because you have already updated the list. That print will have to come before executing any mutations to the list (unless you made a copy).
Transcribed Image Text:Probably don't need my input anymore, but... For Option 3, you don't ask the userto enter in the balance of the new client info. Also, you should be vlaidating user inputs to make sure they are valid before proceeding with your program, or they might crash it. For option 6, you forgot to also sort the balance list to ensure the balance data stays paired with proper client name. AndyNardo Today at 11:17 AM Smart move on printing to screen the updated lists at the end of the program. I was a dum dum and wrote that same damn statement for each option. What a waste of script. However! You don't actually print the original List despite printing to screen "Your original List:". In fact, you wouldn't be able to do that at the end of the program anyways, because you have already updated the list. That print will have to come before executing any mutations to the list (unless you made a copy).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education