[Tutor] Re-Project Vector Datasets

Alan Gauld alan.gauld at yahoo.co.uk
Tue Oct 27 21:01:58 EDT 2020


On 27/10/2020 19:37, Steven Douglas wrote:

>     if currentFCSRName == targetSRName:
> 
>     else:

There is no body after the if so Python sees the else as
being in the wrong place. If you must have an empty
body use 'pass':

if boolean_expression:
    pass
else:
   # go for it...

> Error:  IndentationError:  expected an Indented block -- on line 36 (the
> last "else:"

But usually you can invert the boolean logic to put
what is in the else part into the if part.
So in your example

if not (currentFCSRName == targetSRName):
    # put the old 'else' code here
# no else needed...

OR if you prefer:

if currentFCSRName != targetSRName:
    # put the old 'else' code here
# no else needed...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list