How to combine elements from two lists into a third?

前端 未结 6 1257
星月不相逢
星月不相逢 2020-12-06 04:09

I have two lists a and b:

a  =   [3,    6,   8,   65,   3]
b  =   [34,   2,   5,   3,    5]

c gets [3/34, 6/2, 8/5, 65/3, 3/5]
         


        
6条回答
  •  时光说笑
    2020-12-06 04:30

    You can use the following code:

    a  =   [3,    6,   8,   65,   3]
    b  =   [34,   2,   5,   3,    5]
    
    c = [float(x)/y for x,y in zip(a,b)]
    print(c)
    

提交回复
热议问题