how to change to list comprehension for below code in python

后端 未结 0 768
花落未央
花落未央 2021-01-25 06:53

I need help with the list comprehension equivalent for the below normal loop code

a = [1,2,3]
b = []
for i in a :
    if i == 2 :
        b.append(i*2)
    else :         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题