Hack Forums
[Python] Invalid syntax error - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Invalid syntax error (/showthread.php?tid=5831910)



Invalid syntax error - Zak - May 1, 2018

Code
import csv

stores = []
total = 0

with open('report.csv') as csvDataFile:
    csvReader = csv.reader(csvDataFile)

    for row in csvReader:
        if csvReader.line_num == 1:
             continue    # skip first row
             if row[8] == 'D'
                    stores.append(row[3])

stores = set(stores)

for store in stores:
    print(store)

Getting a syntax error
if row[8] == 'D'
^
SyntaxError: invalid syntax

Can anyone help?


RE: Invalid syntax error - minimalist - May 1, 2018

You're missing a colon in the line above the line of interest


RE: Invalid syntax error - F.A.S.T - May 2, 2018

add : after that line.