Pythonサイクルif and for a more write

316 ワード

x =[1,2,3,4,5]
y =[6,7,8,9,10]
q = [a + b for a in x for b in y if a%2 == 0 and b%2 == 0]
#   x , y    ,         ,     
#a +b      for a in x    x     for b in y    y    if a%2 == 0 and b%2 == 0   x,y
#     ,a%2 and b%2       
print(q)
w =[ a for a in x if a%2 == 0 ]
#     x ,      
print(w)