[Tutor] User input question

shey crompton shey@argonaut.com
Thu, 8 Aug 2002 15:32:08 +0100


That's got rid of the error message, thanks.
It now just squares the number that the user inputs, and also returns 'None'
on the line below (confused?). 

I am thinking I need a range command to get it to do multiply within a
range. I have just tried adding:
	For n in range(1,13):
Between the 'def' line and the if statement with no result. Oh well, gives
me something else to ponder on during an otherwise boring day at work. :-)


 -----Original Message-----
From: 	Kyle Babich [mailto:kb@mm.st] 
Sent:	08 August 2002 15:02
To:	shey crompton; tutor
Subject:	Re: [Tutor] User input question

I'm still a newbie to python so I am taking my best guess in saying to
un-indent the print that is causing the error.

On Thu, 8 Aug 2002 14:15:32 +0100, "shey crompton" <shey@argonaut.com>
said:
> I have been trying to modify a script that prints out the times tables
> to
> one that asks the user to input which times table they would like
> printed
> out (between 1 and 13).
> I have tried so many different ways of doing this without any success.
> I am
> sure it's a simple answer, but I am starting to get frustrated.
> The script below is my latest attempt, and the error message I get is
> below
> it. 
> Hints, and tips greatly appreciated.
> 
> Shey
> 
> 
> def timestab(n):
>     if i < 13:
>         print "%d x %d = %d" % (i,n,i*n)
>     else:
>         print "Only positive numbers between 1 and 12 please!"
> 
> i = input('Try a number ')
>     print timestab(i)
> 
> 
> The error message is:
> 
> File "C:\Documents and Settings\shey\Desktop\timesTab_8.py", line 15
>     print timestab(i)
>     ^
> SyntaxError: invalid syntax
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

--
Kyle