mardi 31 octobre 2017

Python: Element-wise implementation of 'in' conditional operator

So, I have two lists:

x =[170 169 168 167 166 165 183 201 219 237 255 274 293 312 331 350]
y =[201,168]

I want to write a conditional if statement that is true only if all the contents of y are in x. How do I do this?

E.g. -- assert(y[0] in x) and assert(y[a] in x) both give True, but assert(y in x) gives False. Similarly, assert( any(y) in x ) raises an error as well.

Aucun commentaire:

Enregistrer un commentaire