Answer to Question #208584 in Python for Andu

Question #208584

How to explain this code?


elif(choice=="3"):#Search for a user

      name =input("Enter the name of account: ")

      surname =input("Enter the surname of the account: ")

       

      accountExist=False

      for acc in accounts:

        if acc.getName()==name and acc.getSuname()==surname:

          acc.displayAccountInformation()

          print("")

          accountExist=True

      if accountExist==False:

        print("\nThe account does not exist.\n")


1
Expert's answer
2021-06-19T07:00:30-0400
elif(choice=="3"):#Search for a user


    #Ask user to input name
    name =input("Enter the name of account: ")


    #ask user to input surname
    surname =input("Enter the surname of the account: ")


       
    #set accountExit to False
    accountExist=False


    #check every value in accounts
    for acc in accounts:


        #Compares input values with the one in db and if they are the same
        if acc.getName()==name and acc.getSuname()==surname:


            #displays account information by callin displayAccountInformation()
            acc.displayAccountInformation()


            print("")


            #accountExist changes to False to stop the loop if account exist
            accountExist=True


        #set accountExist to false if account does not exist and print the error
        if accountExist==False:


        print("\nThe account does not exist.\n")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS