+ 1

How to print %2, even numbers from lists in list?

m=[[1,2,3], [4,5,6], [7,8,9]] I want to do something like: r[1] for r in m if r[1]℅2==0

7th Oct 2020, 3:31 PM
Martyna Tomaszewska
Martyna Tomaszewska - avatar
4 Answers
+ 5
[[j for j in i if j % 2 == 0] for i in m]
7th Oct 2020, 3:33 PM
Seb TheS
Seb TheS - avatar
0
Ok, but why it prints empty window?
7th Oct 2020, 3:51 PM
Martyna Tomaszewska
Martyna Tomaszewska - avatar
0
Because the list wasn't printed.
7th Oct 2020, 4:04 PM
Seb TheS
Seb TheS - avatar
0
True :) thx
7th Oct 2020, 5:22 PM
Martyna Tomaszewska
Martyna Tomaszewska - avatar