[Tutor] Help with class example

Frank Pontius yahufpontius at yahoo.com
Sat Oct 27 22:51:07 CEST 2012

But, this is an if.

From my Android phone on T-Mobile. The first nationwide 4G network.

bob gailer <bgailer at gmail.com> wrote:

On 10/27/2012 1:26 PM, Frank Pontius wrote:
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

-----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:
get rid of the colon. That is used only at the start a compound statement e;g; if, else, for, while, def class, ...
>              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.
An IDE is an exception to that request since it displays certain exceptions in a different way.

Bob Gailer
Chapel Hill NC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121027/c7b3e998/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RAW
Type: image/jpeg
Size: 38506 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20121027/c7b3e998/attachment-0001.jpe>

More information about the Tutor mailing list