Need help on a project To :"Create a class called BankAccount with the following parameters "

Jason Friedman jsf80238 at gmail.com
Fri May 12 23:49:29 EDT 2017


>
> menu_list = ["O -open account"]
> menu_list =["l - load details"]
> menu_list =["D- display details"]
> menu_list =["A - Make deposit"]
> menu_list =["W- Make withdraw",]
> menu_list =["S - save"]
> menu_list =["Q - quit"]
>
> command = input("command:")
> if command.upper() == "O":
> open_()
> elif(comman.upper() =="l":
> load_()
> elif(comman.upper() =="a":
> deposit_()
> elif(comman.upper() =="W":
> withdraw_()
> elif(comman.upper() =="s":
> save_()
> elif(comman.upper() =="q":
>

There's a lot of code there so I will comment only on the sections above.

The first section does not do what I think you want:  a list with 7
options.  It makes a list with one option, then overwrites it with a new
list with one option, and so on.  You want something like:
menu_list = [
    "O - open account"
    "L - load details"
    "D - display details"
    "A - Make deposit"
    "W - Make withdraw",
    "S - save"
    "Q - quit"
]

The second section has mistyped "command".  You also added underscores to
your method names.  Further, some of your match strings are lowercase, and
you only want to compare the first letter anyway.  Try:
command = input("command:")
if   command.upper().startswith("O"):
    open()
elif command.upper().startswith("L"):
    load()
elif command.upper().startswith("A"):
    deposit()
elif command.upper().startswith("W"):
    withdraw()
elif command.upper().startswith("S"):
    save()
elif command.upper().startswith("Q"):
    quit()



More information about the Python-list mailing list