Im have 2 arrays, for example: [1, 2, 3] and [4, 5, 6] How do i merge them into 1 array?: [1, 4, 2, 5, 3, 6] ? help please
            Asked
            
        
        
            Active
            
        
            Viewed 299 times
        
    -2
            
            
        - 
                    Use extend() list method – balderman May 31 '20 at 18:23
- 
                    1What have tried? – Red May 31 '20 at 18:24
- 
                    Write a `for` loop – Thomas Weller May 31 '20 at 18:25
- 
                    `[y for t in zip(l1,l2) for y in t]`? if both are equal length lists. – Ch3steR May 31 '20 at 18:26
1 Answers
1
            
            
        If the order is not important can just use +:
a = [1, 2, 3]
b = [4, 5, 6]
c = a + b
Otherwise you can do something like this:
a = [1, 2, 3]
b = [4, 5, 6]
c = []
for i, j in zip(a, b):
    c += [i, j]
 
    
    
        Pavel Botsman
        
- 773
- 1
- 11
- 25
