Select to view content in your preferred language

if else statement not working.

834
2
06-13-2013 10:19 AM
MadanBurathi
Deactivated User
Hi this is madan I am new in Arcpy scirpting I was just writting follwong program in python window in Arcgis10.1 there is comming parsing error as shown below.
please someone help me how to correct it.



>>> def mm(var):
...     if var==200:
...         print "I am madan"
...         print ""
...         else:
...             print "I am nothing"
...             print ""
...            
Parsing error SyntaxError: invalid syntax (line 5)
Tags (2)
0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor
It is kind of hard to tell without you using the
 tags, for formatting purposes... The following works fine for me:

def mm(var):
    if var==200:
        print "I am madan"
        print ""
    else:
        print "I am nothing"
        print ""

mm(200)
0 Kudos
RhettZufelt
MVP Notable Contributor
One of the first things you need to know about python is that indentation is everything.

That is how it keeps track of your if blocks, etc.

That is why Lucas's re-write works for him.

R_
0 Kudos