Python's Syntax
Erik Max Francis
max at alcyone.com
Fri Mar 1 12:10:43 EST 2002
David Russell wrote:
> I've had a look at a couple of tutorials for Python and it appears
> like
> this:
>
> if condition == TRUE:
> do this
>
> How do you tell it when to stop? I just can't figure out how to do it.
> Could
> somebody explain it to me please, even though I have a strange
> suspicious
> that it is one of the simplest deatils imaginable.
That's an if statement, there's no "stopping" involved; it simply tests
the condition and then executes the "then" clause if it evaluates to
true.
You probably meant somethinng like a while loop:
while condition:
statements
this continues to execute the statements while condition evaluates to
true. It's precisely the same as C's
while (condition)
{
statements
}
> Also, another thing about Python's syntax. Are statements just
> sperated by
> their lines, or do they have some form of seperator (like a
> semi-colon)?
You can use semicolons to separate multiple statements on the same line:
x = 1; print x
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Laws are silent in time of war.
\__/ Cicero
Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
An Esperanto reference for English speakers.
More information about the Python-list
mailing list