Python Files: Hacking the Fender

https://www.codecademy.com/paths/data-science/tracks/dscp-python-fundamentals/modules/dscp-python-files/projects/hacking-the-fender

Can anyone advise what needs to be fixed from below code? I get this error and can’t break throught from task 6. Thank you.

Traceback (most recent call last):
File “script.py”, line 7, in
compromised_users.append(password_csv[‘Username’])
TypeError: string indices must be integers

import csv

compromised_users=

with open(‘passwords.csv’) as password_file:

password_csv=csv.DictReader(password_file)

for line in password_csv:

password_csv=password_file.readline()

compromised_users.append(password_csv['Username'])

What type is password_csv when you’re using it in that statement? If you’re unsure you can check with print(), type() etc. just to make sure it’s what you expect.