title: Why am I getting an syntax error here? Python and MongoDB
body: <p>This is the error</p>
  
  <pre><code>  File "crime.py", line 106
  result_cursor = collection.find({$and: [{'Year': {$gte : 2000}}, {year: {$lte : 2010}}]}, {"Murder": 1, "Robbery": 1, "Burglary": 1, "Theft": 1, "Year": 1})
                                   ^
  </code></pre>
  
  <p><code>SyntaxError: invalid syntax</code></p>
  
  <p>I'm getting a syntax error here and I can't figure it out. I have looked at the find() documentation and there is no example that decries my situation. here is the rest of my code.
  I am taking data from a large CSV file in mongo db and using pygal to output it to graphs. In the 4th question/graph attempt I am trying to make a graph for murder, robbery, burglary and theft stats from 2000 to 2010 in a dot graph representation.</p>
  
  <pre><code>
  #import pymongo module
  import pymongo
  #import pygal graphing module
  import pygal
  
  #Connect to the mongodb server
  #change username and password below with your own
  myclient = pymongo.MongoClient(host = "mongodb://localhost:27017/",
  serverSelectionTimeoutMS = 3000,
  username="",
  password='')
  
  #Select the module12 database
  db = myclient["mod12"]
  
  #Choose the crime collection from the module12 database
  collection = db["crime"]
  
  #Plot the annual statistics for Murder and Robbery for the entire dataset  (1994 - 2013)
  result_cursor = collection.find({},{"Murder": 1, "Robbery": 1, "Year": 1})
  
  #Create empty lists to store murder and robbery data in
  murder = []
  robbery = []
  years = []
  
  #store the murder and robbery stats into lists
  for doc in result_cursor:
      murder.append(doc["Murder"])
      robbery.append(doc["Robbery"])
      years.append(doc["Year"])
  
  #Export the data in a chart to an SVG file
  bar_chart = pygal.Bar()
  bar_chart.title = "Demo: Murder &amp; Robbery Stats"
  bar_chart.x_labels = map(str, years) #set x axis labels to the years
  bar_chart.add('Murder', murder) # add murder data to the graph using the murder list
  bar_chart.add('Robbery',robbery) # add robbery data to the graph using the robbery list
  bar_chart.render_to_file('images/test_chart.svg') #render the chart to an SVG file
  
  #If program is successful print this
  print("Program executed successfully")
  
  ### Write your queries and create your charts below
  
  result_cursor = collection.find({},{"Burglary" : 1, "Theft": 1, "Year":1})
  
  burglary = [] 
  theft = []
  years = []
  
  for doc in result_cursor:
      burglary.append(doc["Burglary"])
      theft.append(doc["Theft"])
      years.append(doc["Year"])
  
  bar_chart = pygal.Bar()
  bar_chart.title = "Burglary and Theft Stats"
  bar_chart.x_labels = map(str, years)
  bar_chart.add('Burglary', burglary)
  bar_chart.add('Theft', theft)
  bar_chart.render_to_file('images/question_1.svg')
  
  print("Q1 done right")
  
  result_cursor = collection.find({},{"Motor Vehicle Theft": 1, "Property Crime": 1, "Year": 1})
  
  motortheft = []
  propertycrime = [] 
  years = []
  
  for doc in result_cursor:
      motortheft.append(doc["Mother Vehicle Theft"])
      propertycrime.append(doc["Property Crime"])
      years.append(doc["Year"])
  
  line_chart = pygal.Line()
  line_chart.title = 'Motor Vehicle Theft and Property Crime stats'
  line_chart.x_labels = map(str, years)
  line_chart.add('Motor Vehicle Theft', motortheft)
  line_chart.add('Property Crime', propertycrime)
  line_chart.render_to_file('images/question_2.svg')
  
  print("Q2 done right")
  
  result_cursor = collection.find({},{"Violent Crime": 1, "Aggravated Assault": 1})
  
  vcrime = []
  aassault = [] 
  
  for doc in result_cursor:
      vcrime.append(doc["Violent Crime"])
      aassault.append(doc["Aggravated Assault"])
  
  line_chart = pygal.HorizontalBar()
  line_chart.title = 'Violent Crime and Aggravated Assualt Stats'
  line_chart.add('Violent Crime', vcrime)
  line_chart.add('Aggravated Assault', aassault)
  line_chart.render_to_file('images/question_3.svg')
  
  print("Q3 done right")
  
  
  **result_cursor = collection.find({$and: [{'Year': {$gte : 2000}}, {year: {$lte : 2010}}]}, {"Murder": 1, "Robbery": 1, "Burglary": 1, "Theft": 1, "Year": 1})**
  
  murder = []
  robbery = []
  burglary = []
  theft = []
  years = []
  for doc in result_cursor:
      murder.append(doc["Murder"])
      robbery.append(doc["Robbery"])
      burglary.append(doc["Burglary"])
      theft.append(doc["Theft"])
      years.append(doc["Year"])
  
  dot_chart = pygal.Dot(x_label_rotation=30)
  dot_chart.title = 'Murder, Robbery, Burglary, &amp; Theft Stats 2000-2010'
  dot_chart.x_labels = map(str, years)
  dot_chart.add('Murder', murder)
  dot_chart.add('Robbery', robbery)
  dot_chart.add('Burglary', burglary)
  dot_chart.add('Theft', theft)
  dot_chart.render_to_file('images/question_4.svg')
  
  print("Q4 done")
  
  
  </code></pre>