When running the following query I keep getting TypeError: ‘NoneType’ object is not iterable. I tried if data is not None: but don’t seem to work. I apprcieate any suggestion on how to fix.

pgCon = Postgres(username='username', password='password', servername='localhost', database='database')
with open("sample.txt", "r") as file:
    data = file.read().splitlines()
for key in range(len(data)):
    pgCon.query(('''update my_table set status = 'YES' where id in (''' + data[key] +''')'''))