new guy

N

nards_collective

I'm new to Python, in fact I'm new to programming. I'm trying to write
a simulation program, for a biology class I'm teaching next year. the
following code is giving me trouble and i can't work out why.

if e>= 1 :
a=e
else :
a=0


I keep getting a syntax error.
This piece of code is meant to keep the value of a equal to or grater
than 0. Any odeas would be appreciated.

THAnkS
NArDS
 
K

KefX

if e>= 1 :
a=e
else :
a=0
I keep getting a syntax error.

You sure this causes it? It doesn't seem to be great style to me (should be no
space before a colon, spaces around the equals sign, space before the >=
operator), but that won't cause a syntax error.

What is the exact error message you receive? Even better, post the whole
traceback.

- Kef
 
C

Cameron Laird

I'm new to Python, in fact I'm new to programming. I'm trying to write
a simulation program, for a biology class I'm teaching next year. the
following code is giving me trouble and i can't work out why.

if e>= 1 :
a=e
else :
a=0


I keep getting a syntax error.
This piece of code is meant to keep the value of a equal to or grater
than 0. Any odeas would be appreciated.
.
.
.
Others have already spoken to the details of syntax.
The best help I can give is to recommend you read
<URL: http://www.catb.org/~esr/faqs/smart-questions.html >.
Also, although it's nominally about a different language,
you might like <URL: http://wiki.tcl.tk/RequestHelp >.

Being "new to programming" is exciting! You'll accelerate
your progress as you develop an instinct to change
I keep getting a syntax error
to
I see the specific syntax error, '...'
[copied EXACTLY from the screen].

Python has a lot to offer, and already has many successes
in, biology and other physical sciences. Some day the
references in <URL: http://
phaseit.net/claird/comp.programming/open_source_science.html >
might interest you.
 
R

Ron Adam

I'm new to Python, in fact I'm new to programming. I'm trying to write
a simulation program, for a biology class I'm teaching next year. the
following code is giving me trouble and i can't work out why.

if e>= 1 :
a=e
else :
a=0


I keep getting a syntax error.
This piece of code is meant to keep the value of a equal to or grater
than 0. Any odeas would be appreciated.

THAnkS
NArDS

1. Check that you didn't type "If" instead of 'if', or "Else"
instead of "else".

2. Look at the line above the if statement, it may be the actual line
with the error in it. Tt may be missing a ending quote, bracket, or
parentheses, or be incomplete in some other way.


_Ronald Adam
 
P

Peder Ydalus

....and remember to declare the e somewhere above the snippet to avoid a
NameError...

- Peder -
 
M

Mark Roach

if e>= 1 :
a=e
else :
a=0


I keep getting a syntax error.
This piece of code is meant to keep the value of a equal to or grater
than 0. Any odeas would be appreciated.

you could also use a = max(0, e)

-Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top