[Tutor] Problems with pytz module

Alan Gauld alan.gauld at yahoo.co.uk
Wed Jul 19 18:52:01 EDT 2017


On 19/07/17 20:58, Daniel Bosah wrote:

> class Account:
>     def deposit(self,amount):
>         if amount > 0:
>             self.balance += amount
>             self.show_balance()
> 
> self.transaction_list.append(....

>     def withdrawl(self,amount):
>          if 0 < amount <= self.balance:
>                 self.balance -= amount
>          else:
>             print "The account must be greater then zero and no more then
> your account balance"
>          self.show_balance()

Ignoring the indentation issue, you only write transactions for
deposits. nothing for withdrawals.

>     def show_transactions(self):
>         for date, amount in self.transaction_list:
>             if amount > 0:
>                 tran_type = "deposited"
>             else:
>                 tran_type = "withdrawn"
>                 amount *= -1 # to show negative number
>                 print "{:6} {} on {} (local time was {})".format(amount,

But here you only print for withdrawals but not for deposits.

So you try to print non existent transactions.

> Im using Ubuntu Linux. My problem is that I cannot get show_transactions to
> print out on the console.

Since there shouldn't be any that match that's not surprising.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list