Get_movies_by_country invalid syntax

I realize the assignment is late but I’m still trying to get a working solution. I’m getting invalid snytax on the n of return. I’ve downloaded the latest db.py that fixed the previous indent issues. Not sure whats going on here though? Any tips in the right direction?

def get_movies_by_country(countries):
"""
Finds and returns movies by country.
Returns a list of dictionaries, each dictionary contains a title and an _id.
"""
try:

    """
    Ticket: Projection

    Write a query that matches movies with the countries in the "countries"
    list, but only returns the title and _id of each movie.

    Remember that in MongoDB, the $in operator can be used with a list to
    match one or more values of a specific field.
    """
	
    # TODO: Projection
    # Find movies matching the "countries" list, but only return the title
    # and _id.
return list(db.movies.find({"countries": {"$in": [countries]}},{"title": 1, "_id":1}))
except Exception as e:
    return e

It looks like your return statement needs an indent:

try:
    # TODO: Projection
    return list(db.movies.find({"countries": {"$in": [countries]}},{"title": 1, "_id":1}))

except Exception as e:
    return e
1 Like

Don’t pass the countries value in an array.

1 Like

As @murali_kannaiah said, it’s should be like this:
{"$in": countries}, because countries itself is an array, please check test_projection.py

1 Like