I have the following Python dict. I'm trying to do a check with n if statement that payload contains "token"
{'payload': {'token': '3u4td7393493d9304'}, 'type': 'send'}
Below is the python code
if message['payload'] == 'token':
print("GOT IT");
print(message)
elif message['payload']['type'] == 'timedout':
print("TIMEDOUT!")
elif message['payload'] == 'locked':
print("LOCKED!")
done.set()
The current if statement for token is wrong. What is the proper way of checking if payload has "token" inside it?
typeisn't in thepayloaddict, it's in themessagedict. Shouldn't it bemessage['type'] == 'timedout'?