[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
parens!
            print "TRANSACTION COMPLETED"

The error I got was:

            exit()
  File "<input>", line 15
    print "TRANSACTION COMPLETED"
        ^
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.

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list