0
NoobSoustraire à partir d'une liste en annexe d'entrée avec une sortie de la balance courante
Je suis en train d'écrire un script qui donne un solde courant. Je me trompe sur les fonctions élémentaires déclarées de python.
J'ai besoin aussi:
- acceptent un équilibre via l'entrée
- ajouter une liste des transactions
- prendre les un par un dans l'ordre de leur entrée
- imprimer un total en cours d'exécution
- utiliser pyhtmltable pour rendre la sortie en format html prête à copier et coller
code:
# transaction posting on available balance
import PyHtmlTable
import twodarr
import string,re
import copy
import sys
posting_trans = [] #creating a list of posting debits here
avail_bal = int(input('What is the balance available to pay transactions?')) #getting the starting balance
while True: #building up the list of transactions
ans = input('Please enter the debits in order of posting one at a time. If there is no more, please enter 0:')
if int(ans) == 0:
break
if ans > 0: # to get out of loop
posting_trans.append(ans)
num_trans = int(len(posting_trans)) #counting the number of transactions
print "<b> Beginning available balance of",avail_bal," </b> " # start of the html table
tabledict = {'width':'400','border':2,'bgcolor':'white'}
t = PyHtmlTable.PyHtmlTable(2, 1 , tabledict)
t.setCellcontents(0,0,"Transactions") #header cells
t.setCellcontents(1,0,"Available Balance")
while True: #trying to create the rest of a dynamic table
if countdown == 0:
break
for countdown in range(1,num_trans):
t.add_row(1)
def newer_bal():
newer_bal(avail_bal - posting_trans[countdown])
t.setCellcontents(0, 1, posting_trans[countdown])
t.setCellcontents(1, 1, newer_bal)
t.display()