N
N
novicheck2016-08-02 16:54:43
Python
novicheck, 2016-08-02 16:54:43

How can I check if an element is in a list?

I need to get a list of people matching person : start date but I need people only for a certain parameter. Parameter:

uidpay = list(db.events.distinct("uid", {"is_buyer": 1}))
and his example:
[u'6210A609-03CD-4646-9B69-D6F0C455D5E7', u'14738D3A-E80E-4A51-97A9-787E646AEF18']
. This is how I get the start time:
lel = list(db.events.aggregate(
[
  {"$match": {"eventName" : "Level 1"}},
  {"$group": {"_id": "$uid", "dateofstart": {"$addToSet": "$updated_at"}}}
]))

Here is an example output (already done in a convenient way):
meh = [{"u'F829CB26-CF2B-4896-92D6-17B1519948C7'": u'F829CB26-CF2B-4896-92D6-17B1519948C7'}, {"u'6071a6fb-4d93-4589-84a7-8a8c8ce37094'": u'6071a6fb-4d93-4589-84a7-8a8c8ce37094'}]

and I'm trying to build a check like this:
for players in meh:
  kost = str(players.keys())
  print(kost)
  kost = kost[2:41]
  print(kost)
  if kost == uidpay:
    dateoflvl1pay.append(players)
print(dateoflvl1pay)

I understand that the code is bad, but still the question is how to correctly check for the presence of elements in the list?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question