I have a MongoDB and documents are like this:

I have a text file that include some words and their sentiment scores. If the word is in the testcollection as "surfaceEnd", I want to update some fields. Otherwise, I want to insert a new row.
for w in words:
print w
if db.testcollection10.find({ 'surfaceEnd': w }) == True:
posnum = float(get_positive(cols))
negnum = float(get_negative(cols))
db.testcollection.update({ 'surfaceEnd': w}, {"$set": { 'posEnd': posnum,'negEnd': negnum,'findEnd' : 1 }})
i = i + 1
else:
cursor = db.collectionNelly.find({ 'surfaceStart': w })
for document in cursor:
relation = document['rel']
word = document['surfaceEnd'].encode('utf-8')
posnum = float(get_positive(cols))
negnum = float(get_negative(cols))
if 'Synonym' in document['rel']:
db.testcollection1.insert ({ 'surfaceStart': w,'posStart': posnum, 'negStart': negnum, 'surfaceEnd': word,'posEnd': posnum,'negEnd': negnum, 'rel' : document['rel'], 'findEnd' : 0 })
Unfortunately, the testcollection could not be created. What is the problem in this code?