[Tutor] Help with class example

Frank Pontius yahufpontius at yahoo.com
Sat Oct 27 19:26:32 CEST 2012


Here ya go!

Can't do what you want as this is a programmatic error from interrupter.
Only a screen shot will tell you the full situation.  I have class example
which is to be used for our homework, and I copied it into IDLE and it won't
work, with error below.  I've tried several ways to work around this

 

Thanks

Frank

 



 

 

 

 

 

 

 

 

 

-----Original Message-----
From: Dave Angel [mailto:d at davea.name] 
Sent: Friday, October 26, 2012 7:55 PM
To: Frank Pontius
Cc: tutor at python.org
Subject: Re: [Tutor] Help with class example

 

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 off.

 

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

 

-- 

 

DaveA

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121027/80ec4072/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 38506 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20121027/80ec4072/attachment-0001.jpg>


More information about the Tutor mailing list