alex alex - 4 years ago 274
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)

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download