0

Suppose I am having two list of lists as :

a=[['10', '1', '10-08-2017'], ['10', '1', '27-07-2017']]

b=[['SKS', ' SKSIND '], ['Arcotech', ' ARCOTECH ']]

Expected output:

[['SKS', ' SKSIND ','10', '1', '10-08-2017'], ['Arcotech', ' ARCOTECH ','10', '1', '27-07-2017']]

What I am trying is:

s=[ a[i].extend(b[i]) for i in range(len(a))]
print (s)
#[None, None]---Output

Can someone please help.

ashish
  • 87
  • 1
  • 6
  • `list.exted()` changes the lists in-place, it doesn't return a new list. You can use `zip` and `add` operation instead. – Mazdak Aug 03 '17 at 07:45
  • 2
    Here is an exact duplicate https://stackoverflow.com/questions/7806511/python-merge-nested-lists – Mazdak Aug 03 '17 at 07:49
  • Thanks it works now.. – ashish Aug 03 '17 at 07:53
  • for i in range(len(a)): a[i].extend(b[i]) print (a)------[['SKS', ' SKSIND ', '10', '1', '10-08-2017'], ['Arcotech', ' ARCOTECH ', '10', '1', '27-07-2017']] – ashish Aug 03 '17 at 07:54

0 Answers0