[Tutor] Program Problems

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jul 20 00:13:35 CEST 2004

> If you see a problem, can you tell me?
> http://rafb.net/paste/results/88yf5V76.html
> I cannot figure out the errors.  Or this list.

That's better,

def MenuOption(self, option, Account):
        if option == 1:
            Account.deposit(input("Deposit amount:$")  <--- mismatched
            print "TRANSACTION COMPLETED"

The error I got was:

  File "<input>", line 15
SyntaxError: invalid syntax

Which showed that it was in the class definition and which elif
statement to look at. Then I noticed the missing paren.

The other wee point is that input() is not recommended because Python
literally evaluates the user input which could be a malicious python
command! Better to use raw_input and convert to an int or float.


Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list