mardi 3 novembre 2015

Python lists if else concatenation adding elements

I'm trying to do this:

for i in range(len(daysDial)):
 if diasDial[i] in daysPresence:
   for j in range(len(daysPresence)):
      if daysDial[i]== daysPresence[j]:
        rowsPresence.append(dataPresencePy[j][1])

    else:
        rowsPresence.append("no presence")

in this other way:

rowsPresence = [dataPresencePy[j][1]  for i in range(len(daysDial)) if
daysDial[i] in daysPresence else "no presence" for j in
range(len(daysPresence))   if daysDial[i]== daysPresence[j]]

but it doesn't works properly. Is it posible to do?

Thanks!

Aucun commentaire:

Enregistrer un commentaire