ComeçarComece de graça

We've got options

Sometimes, we wish to find documents where a field's value matches any of a set of options. We saw that the $in query operator can be used for this purpose. For example, how many laureates were born in any of "Canada", "Mexico", or "USA"?

If we wish to accept all but one option as a value for a field, we can use the $ne (not equal) operator. For example, how many laureates died in the USA but were not born in the USA?

Este exercício faz parte do curso

Introduction to MongoDB in Python

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Save a filter for laureates born in the USA, Canada, or Mexico
criteria = { ____: 
                { "$in": ____}
             }

# Count them and save the count
count = db.____.____(____)
print(count)
Editar e executar o código