Write a program that prompts the user for their monthly deposits and withdrawals from their checking account. After each transaction, output the balance and the amount withdrawn or deposited. At the end of the program, output a formatted table of the transactions. Use the Python format function to only display two decimal places. Use a Python list to keep track of the transactions and balances.

i dont know how to this someone can hellp ?

def main():
    print("This program calculates th user's monthly deposits and withdrawals")
currentb = 0
transaction = 0
loop1 = eval(input("enter the number of transactions: "))
for i in range(loop1):
    currentb = currentb+transaction
loop2 = eval(input("Enter the initial balance of your account: "))
for i in range(loop2):
 loop3 = input("Enter the amount of transaction: ")

this is my beginning :(

for loop with user input count is not as user friendly as input until special value, say 0. Using eval on direct user input is considered bad idea as with suitable input user can do any OS command.

Why are you having the user input the number of transactions? It just seems to me like that would become repetitive since most transactions in a month are only made once. To subtract the amount from the total balance you should - from current balance. I'll give you a hint as to how I would've started it, assuming you don't know how to do exception handling.

transactions = []
initialb=input("Enter the initial balance of your account: ")
currentb = initialb
def decision():
    decide=input('Transaction deposit or withdrawal?: ')
    decide.lower()
    if decide[0]=='w':
        withdrawn()
    elif decide[0]=='d':
        deposited()
def withdrawn():
    tran=input("Enter the amount of transaction: ")
    currentb-=tran
    bank_event='%s taken from account. Balance after transaction %s' % (tran,currentb)
    transactions.append(bank_event)
def deposited():
    tran=input("Enter the amount of transaction: ")
    currentb+=tran
    bank_event='%s deposited into account. Balance after deposit %s' % (tran,currentb)
    transactions.append(bank_event)
decision()

Thanks that helps alot. You are right it makes it repetitive i was just trying to follow my notes but failed.

the outcome should be like this.

Enter the number of transactions: 3
Enter the initial balance of your account: 25

Enter the amount of transaction 1: -5
Your current balance is $20.00
Enter the amount of transaction 2: 10.50
Your current balance is $30.50
Enter the amount of transaction 3: 0.25
Your current balance is $30.75
# Transaction Balance -------------------------
1 $-5.00 $20.00
2 $10.50 $30.50
3 $0.25 $30.75

well there are a couple bugs with that, I haven't tested it, but I can see them.

okay so if you used the general idea of the format I have above and add in the need for the number of transactions then how do you think you could do that? It actually would work pretty smoothly once the bugs are squashed.

i think decision part is unneccesary if you write the acuation currentb=currentb+transaction is already calculates if you deposited or withdrawed. Also i want to use str somewhere to create the list.

the decision part is just a matter of preference, I don't like writing transactions as negative numbers, some do, that's fine. Python has dynamic typing so you don't NEED to use str() anywhere in your list because Python already knows that the bank_event that went into the list is a str. However if it's required for some ridiculous reason you could "though I and almost all pythonistas discourage it" do something odd like

transactions.append(str(bank_event))

But I have to tell you, that looks pretty dumb.

Yes yours is pretty profesional but i just started on programming so i guess begining level requires str. We havent got that practical yet

lol I'm far from professional my friend. I was at about your level last month. But thanks to Daniweb and hard work I'd say I've advanced pretty far, pretty fast.

:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.