[Tutor] Program Questions (original) (raw)

Lloyd Kvam pythonTutor at venix.com
Fri Jul 16 02:08:36 CEST 2004


print "\n" print "TRANSACTION COMPLETED"

You need quotes around string literals, pieces of text that were never assigned a name.

I suspect the elif problems come from using a mix of tabs and spaces in lining things up. Python uses 8 spaces per tab, but your editor could be different. If your editor was using tab stops of four spaces, you could mix tabs and spaces in a way that looked reasonable in your editor, but looks unreasonable to the Python compiler.

I you edit your source code with pythonwin or idle, you should be able to eyeball the problem. Some editors will include a command to convert all tabs to spaces (or vice versa) which is handy for python files.

On Thu, 2004-07-15 at 18:25, mandy bowen wrote: > I just tried a few of the suggestions I received here, but I still get an > invalid syntax error when I try to run the program in this section: >> def MenuOption(self, option, Account): > if option == 1: > print \n > Account.deposit(input(Deposit amount: $)) > print \n > print TRANSACTION COMPLETED > print \n > elif option == 2: > print \n > Account.withdraw(input(Withdraw amount: $)) > print \n > print TRANSACTION COMPLETED > print \n > elif option == 3: > print \n > Account.trans() > print \n > print QUERY COMPLETED > print \n >> The error says that the invalid syntax is in the print command! If I take > all of those print statements out, it tells me the invalid syntax is the > elif??? What is going on here? I'm new to Python, but I know elif is > supposed to be valid... >> __________________________________ > Check out the latest news, polls and tools in the MSN 2004 Election Guide! > http://special.msn.com/msn/election2004.armx >> _________________________ > Tutor maillist - Tutor at python.org > http://mail.python.org/mailman/listinfo/tutor

Lloyd Kvam Venix Corp. 1 Court Street, Suite 378 Lebanon, NH 03766-1358

voice: 603-653-8139 fax: 801-459-9582



More information about the Tutor mailing list