mardi 27 juillet 2021

Python: Else function inside For Loop

I am trying to get my program to output information pulled from a CSV file. The program is determining whether the card and transaction information is valid using a decision structure prior to the main. I have that portion down, but I am not sure how to get the output information in the For loop. This is what I need: a. Number of valid transactions b. Number of In-Valid transactions c. Number of each type of credit card d. Cash dispensed remember the machine only holds $80,000 so it cannot go above that amount i. How many transactions turned away because of lack of funds in ATM machine

e. Deposits made

I have a and b in the For loop already. But I am stuck on the rest. Code Below:

for entry in entryData:
        if entry[CARD.NUMBER] == "CardNumber":
            output.append("{0:<25}{1:<20}{2:<10}".format(entry[CARD.NAME],
                                                        entry[CARD.NUMBER],
                                                        entry[CARD.AMOUNT]))
            output.append("{:->58}".format(""))
        
        else:
            validCard = processCard(entry)
            if (validCard):
                output.append("{0:<25}{1:<20}${2:*>10.2f}".format(entry[CARD.NAME],
                                                            entry[CARD.NUMBER],
                                                            float(entry[CARD.AMOUNT])))
                NumOfValidTransactions+=1
                
            
            else:
                
                NumOfInvalidTransactions+=1
                

Aucun commentaire:

Enregistrer un commentaire