[Tutor] Need to write a python and call it within a python mainprogram (fwd): Thank you very much

Kermit Rose kermit at polaris.net
Sun Feb 19 00:10:44 CET 2006


 
 
 
From: Alan Gauld
Date: 02/18/06 18:00:09
To: Kermit Rose; Danny Yoo
Cc: Tutor
Subject: Re: [Tutor] Need to write a python and call it within a python
mainprogram (fwd)
 
?
 
Indentation is how python determines block sytructure.
 
 
In Python a colon says a block is coming up and everything up to the
next unindented line is part of it. But the indentation must be consistent
(it can be as big or little as you like, but it must be consistent - 2, 3 or
4
spaces is pretty normal)
 
In your case the body of the function had inclonsistent indentation.
 
The other issue is in the format of your if statements:
 
.....    if j = 0,  a,b,c,d = a/2,b/2,c/2,d/2
 
You need to use == as in C for comparisons, unlike C you cannot
do an assignment in a test. The condition must be followed by a colon.
You test thus becomes:
 
if j == 0: a,b,c,d = a/2,b/2,c/2,d/2
 
Note the double equals and the colon.
 
HTH,

*****

Thank you very much!

Kermit  <  kermit at polaris.net  >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060218/cbb5a68d/attachment.html 


More information about the Tutor mailing list