alex alex - 5 months ago 32
Python Question

SyntaxError: invalid syntax in if ... in ... statement

I want to check if the ID of an user is in the unfollowed_users JSON array:

if "1691998847" in unfollowed_users["unfollowed_users"]:

The JSON array looks like this:

{"unfollowed_users": ["1691998847", "2286995142", "144484896"]}

However, I get this error:

File "/home/alex/instabots/shiba_inu_test/", line 535
if uself.media_by_tag[0]["owner"]["id"] in unfollowed_users

What could be the reason?

Note: This is how I'm setting

with open("unfollowed_users.json", "r") as fp:
unfollowed_users = json.load(fp)


In add a : to the end of your if statement in line 535