I am making a python script with ScratchAttach to automatically answer a certain prompt on my profile, and I have gotten up to the point of getting messages from my profile. Now how do I check if the "Content" key of one of those objects contains the example text "Hello World"? If it wasn't clear, I am doing this in Python.
[{'CommentID': '317977750', 'User': 'shieldroy', 'Content': 'Can you pls advertise my studio and tell people to comment " generic" on my profile.', 'Timestamp': '2024-03-10T04:47:53Z', 'hasReplies?': False}]
I haven't really tried a lot, because I am pretty new to python.
You can access key/value pairs in a dict using
my_dict['Content'], so you can doWhat this does is first check if the key exists in the dictionary, and then checks if the value is the one you want.
An alternative method is
This makes use of the fact that
my_dict.getreturns the specified default if the key doesn't exist.