fork download
  1. A = [1, 2, 3, 4]
  2. B = [2, 4, 5, 6]
  3. C = [3, 6, 7, 8]
  4.  
  5. D=[]
  6. for elemA, elemB in zip(A, B):
  7. D.append(elemA + elemB)
  8.  
  9. print(D)
  10.  
  11. D = [elemA + elemB for elemA, elemB in zip(A, B)]
  12. print(D)
  13.  
  14. D = [elemA + elemB + elemC for elemA, elemB, elemC in zip(A, B, C)]
  15. print(D)
  16.  
  17. D = [B[posicao] + elemA for posicao, elemA in enumerate(A)]
  18. print(D)
Success #stdin #stdout 0.04s 9388KB
stdin
Standard input is empty
stdout
[3, 6, 8, 10]
[3, 6, 8, 10]
[6, 12, 15, 18]
[3, 6, 8, 10]