[Tutor] Program Questions
Adelein and Jeremy
adeleinandjeremy at yahoo.com
Fri Jul 16 03:28:44 CEST 2004
--- Lloyd Kvam <pythonTutor at venix.com> wrote:
> print "\n"
> print "TRANSACTION COMPLETED"
>
> You need quotes around string literals, pieces of text that were
> never assigned a name.
>
She did have quotes.
This is what you apparently saw:
> > 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
This is what I saw (there are single quotes around each string
literal):
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
> 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.
If indeed that is the problem, then this is also the problem with the
print statement. I see no other error - could be missing something
though.
HTH
Jeremy
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tutor
mailing list