$elemMatch not working with Pymongo

Hello @Lily_B, welcome to the MongoDB Community forum!

The following query will work in PyMongo:

for doc in mydb.mycollection.find( { "buttons.userid": 67890 }, limit = 1 ):
    print(doc)

It will print the first matching document, as you have specified the limit = 1 option. The find method returns a cursor, which will be empty if there is no match.

Since you are trying to check if there are any documents exist, you can use the following query (instead of); it prints the count of matching documents.

print(mydb.mycollection.count_documents({ "buttons.userid": 67890 }))