Hacking the Fender "Invalid Syntax"?

So I’m doing the “Hacking the Fender” exercise right now and it’s been going quite smoothly until I reached point “8” where it asks me to start a new with block… I write my block with the loop and it gives me an invalid syntax error… I don’t see where the error would be tho…
This is my code:

import csv

compromised_users = []

with open('passwords.csv') as password_file:
  password_csv = csv.DictReader(password_file)
  for password_row in password_csv:

with open('compromised_users.txt', 'w') as compromised_users_file:
  for compromised_user in compromised_users:

The error I get is as follows:
File “script.py”, line 10
with open(‘compromised_users.txt’, ‘w’) as compromised_users_file:
SyntaxError: invalid syntax

this is the exercise:

Sometimes the error line number is more of an approximation…
Double check that you’ve closed the parentheses…right after opening the passwords.csv file…in the for loop area.


I just saw what you meant. Parentheses and colons and such are still my arch- nemesis… Thank you very much for pointing it out to me :smiley:

1 Like