alex alex - 1 month ago 10
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"]:
self.write_log("unfollowed_users:")
self.write_log(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/instabot.py", 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
unfollowed_users
:

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

Answer

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

Comments