I have an 2D array (list) in Python like this:
myarr = [ [722,'m',88,77] , [113,'m',99,53] , [746,'m',88,991,633] , [333,'m',777,414,888] ]
I want to get arrays that has 'm' and one of these integers: 722 or 113 or 746.
I must do it in one line and in same structure (I only can change ors and ands), but I can't figure out why it isn't working.
Here is my code:
for arr in myarr: print(arr) if 'm' and (746 or 113 or 722) in arr else print('nah')
It outputs:
nah
nah
[746, 'm', 88, 991, 633]
nah
But, I want it like this:
[722, 'm', 88, 77]
[113, 'm', 99, 53]
[746, 'm', 88, 991, 633]
nah
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire