[Tutor] Help with class example

Dave Angel d at davea.name
Sat Oct 27 04:54:38 CEST 2012

On 10/18/2012 07:59 PM, Frank Pontius wrote:
> Hello,
> I'm taking a beginners course on Python.
> Have class example which is to be used in H/W, which I can't get to work.
> Thus I figure the example is wrong.  But I need this to get H/W done.
> Using 'import random' and random.randrange in function, returning #.
> import random
> def RandomNumberGen ():
> 	if random.randrange(0, 2) == 0:
>              X	return "tails"
> 	return "heads"
> Simple enough, but running in my Python 2.7.3 IDLE - it will not even run,
> and give syntax (red char box) error at the X above.
> Frank

So why is there an X there?  As the compiler tells you, that's a syntax
error. The return statement starts with an 'r'

Please use only text editors to edit code, and use copy/paste to copy
the actual source to your message, while composing the message in text
mode.  We cannot tell who has mangled the code, but only how it happens
to look after the mangling is finished.  If it ever goes through a word
processor, or through an html message (which your is), then all bets are

Another thing.  Copy/paste the actual error message, including the
traceback.  Don't summarize it, or paraphrase it.



More information about the Tutor mailing list