Can't find what's wrong


#1

Link to exercise:
https://www.codecademy.com/courses/learn-python/projects/bank-account

This is the error i get:
TypeError: str returned non-string (type NoneType)



class BankAccount(object):
  balance = 0
  def __init__(self, name):
    self.name = name
  
  def __repr__(self):
    print "%s's account. Current balance: $%.2f" % (self.name, self.balance)
    
  def show_balance(self):
    print "Balance: $%.2f" % (self.balance)
    
  def deposit(self, amount):
    if amount <= 0:
      print "Ivalid deposit. Please enter a positive amount"
      return
    else:
      print "Successfully deposited: $%.2f" % (amount)
      self.balance += amount
      self.show_balance()

  def withdraw(self, amount):
    if amount > self.balance:
      print "Invalid withdrawal. The desired amount exceeds your balance"
    else:
      print "Successfully withdrew: $%.2f" % (amount)
      self.balance -= amount
      self.show_balance()
      
my_account = BankAccount("Antonio")
print my_account
my_account.show_balance()
my_account.deposit(2000)
my_account.withdraw(1000)
print my_account


Thanks for your help.
Antonio


#2

If that error message doesn’t immediately tell you what you need to change, then I’m not sure what information you’re looking for.

Perhaps there’s something you’d like to ask about whatever stops you? Don’t expect others to skip to the conclusion. Ask questions so that you can solve it yourself, and be specific about what you want to know


#3

Despite the non-friendly mail response and no help received from the moderator ionathan, I managed to solve the problem. The topic can be closed, thanks.
On a side note, I’ve spent a good amount of money to learn on this site and I’ve only asked 2 questions in two months. TWO questions.
The question here was pretty clear and I find this response i got, starting with the sentence “If that error message doesn’t immediately tell you what you need to change, then I’m not sure what information you’re looking for”, totally unacceptable.
I understand that you want us to “learn how to learn”, but if I’m lost in some exercise/project I expect your professional help (which I paid for), not some ridiculous passive-aggressive “you’re a ***ard who asks stupid questions” response from a self-declared “cynical” mod.


#4

Here’s the thing.
There was no question.
You stated the problem and expected someone else to take the driver’s seat.

Imagine someone stating that their homework doesn’t pass.
They don’t ask any questions, they want their homework fixed.
You’d probably tell them “good for you”, because it doesn’t seem like they’re looking to solve their own problems.

We do indeed have different perspectives on this, and rather than sharing mine, rather than putting effort into coming up with a diplomatic way of doing so, or putting myself directly at odds with you, I bailed out and removed my post.

As for “codecademy pro” that’s not this forum. And to use that you’d have to direct questions at advisors, and they are almost certainly of yet another attitude - something along the lines of trying to get you to move along and keeping you happy, but not necessarily being able to solve any problems. That’s capitalism for you.

Anyway, I’ll restore my post since it got through regardless.

The way you asked didn’t suit me. I shouldn’t have engaged at all.


#5

I think you’re asking as if you payed to get an answer. Expecting not to have to explain your thoughts, expecting not to have to be the one driving the conversation.

And perhaps that would be fine.

But it’s more like you posted a question on a board at the supermarket. Kinda have to sell it a bit.

And no, I’m not calling you stupid. But when you have an error message pointing out exactly what’s up and it’s very relevant to what you just wrote, then you really really should be explaining why that wasn’t enough, what you’re missing. There may very well be perfectly good reasons, but whoever reads won’t know what those are unless you explain them.


#6

The title is: “Can’t find what’s wrong”
The error: TypeError: str returned non-string (type NoneType)

My logic would be he got X error and he can’t find what’s wrong.
It was a “print” instead of a “return”.
It was 5 am here and I’ve been reading and studying all night. Was stuck on that thing for half an hour trying to understand what was wrong and I couldn’t see why.

You started with that ambiguos sentence your reply and then used the imperative three times in a single sentence. I don’t consider that to be the most kind answer you could’ve come up with.

Anyways, as you also stated, we have different perspective on this and an internet fight is pointless.
Thanks for trying to help, even if I don’t like your methods.
Have a nice day


#7

I did not fit in here, no. A bit of context was needed in order to argue without that being conflict. And that was a botched bail-out on my part.
But I’d argue. I stand by that part. And I’d never tell you it was a print instead of a return. And I’d never ask anything for you, even if I saw it.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.