0

I need to find out how to interweave 2 list. For example:

list1 = ['Hi', ' how', 'you', '?']
list2 = [',', 'are', 'today']

Expected Output:

Hi, how are you today?
  • What have you tried and what went wrong? – Selcuk Jun 25 '18 at 04:51
  • You can use `zip` – Rakesh Jun 25 '18 at 04:51
  • I really haven't tried anything, because I have no idea how to tackle the problem. –  Jun 25 '18 at 04:52
  • https://stackoverflow.com/questions/19883826/interleaving-2-lists-of-unequal-lengths – cs95 Jun 25 '18 at 04:52
  • https://stackoverflow.com/questions/3678869/pythonic-way-to-combine-two-lists-in-an-alternating-fashion – van neilsen Jun 25 '18 at 04:53
  • You don't know how to tackle the problem? Well, how would you do this by hand? You'd take the first string from the first list, then the first string from the 2nd list, and so on. You just need to translate that process to python code. If you don't know how to do *that*, then you need to read a tutorial. *Completing* the program may be difficult, but *tackling* the problem is easy. – Aran-Fey Jun 25 '18 at 04:54
  • Oh thanks. Didn't realize this had already been asked. –  Jun 25 '18 at 04:55
  • You can easily find your answer on stack but it's ok. Using "Zip" you will get the output which you want. >>> res = [output for item in zip(list1,list2) for output in item] – Maulik Barad Jun 25 '18 at 05:24

0 Answers0