jerbear
jerbear

Reputation: 41

If Statement Syntax in Python

I get an error with the below code on the line that says, if (str(listGroup) == "FTPDST"):. I'm pretty sure my if, elif, else statement is correct syntax. Please let me know if my syntax is wrong on that line or anywhere else I get errors because the below code won't run, and it throws an SyntaxError: invalid syntax for the line, if (str(listGroup) == "FTPDST"). My list have been initialized in my code. I'm just not showing it below. Thanks.

def parseConfigForIso(searchString, listGroup):
    fi = open(panConfig,"r") 
    for line in fi:
        if searchString in line: 
            lineList=line.split() 
            for item in listList:
                m = re.search(r'(\d{1,3}.){3}\d{1,3}(-\d{2}|slash\d{2})?',item, re.M|re.I)  
                if m:
                    if (str(listGroup) == "FTPDST"): 
                        ftpDstList.append(str(m.group(0))
                    elif (str(listGroup) == "FTPSRC"):
                        ftpSrcList.append(str(m.group(0)) 
                    elif (str(listGroup) == "SSHDST"):
                        sshDstList.append(str(m.group(0))
                    elif (str(listGroup) == "APPID"):
                        appIdList.append(str(m.group(0))
                    else:
                        print "you inputted an incorrect group as a parameter into the parseConfigForIso function"
    fi.close()
parseConfigForIso('search string', "FTPSRC")

Upvotes: 0

Views: 104

Answers (1)

fzzle
fzzle

Reputation: 1494

You're missing a ) in all .append(str(m.group(0)).

Upvotes: 4

Related Questions