I was trying to insert list values from one list to another, but in a specific order, where dates[0] entered text[1], dates[1] entered text[3] and so on.
dates=['21/11/2044', '31/12/2018', '23/9/3000', '25/12/2007']
text=['What are dates? ', ', is an example.\n', ', is another format as
well.\n', ', also exists, but is a bit ludicrous\n', ', are examples but more commonly used']
I tried this method:
for j in range(len(text)):
for i in range(len(dates)):
text.insert(int((j*2)+1), dates[i])
This was the result, which was incorrect:
['What are dates? ', '25/12/2007', '23/9/3000', '25/12/2007', '23/9/3000',
'25/12/2007', '23/9/3000', '25/12/2007', '23/9/3000', '25/12/2007',
'23/9/3000', '31/12/2018', '21/11/2044', '31/12/2018', '21/11/2044',
'31/12/2018', '21/11/2044', '31/12/2018', '21/11/2044', '31/12/2018',
'21/11/2044', ', is an example.\n', ', is another format as well.\n', ',
also exists, but is a bit ludicrous\n', ', are examples but more commonly used']
I was trying to get back a list that reads like:
['What are dates? ','21/11/2044', 'is an example.\n','31/12/2018', ', is
another format as well.\n','23/9/3000', ', also exists, but is a bit
ludicrous\n', '25/12/2007',', are examples but more commonly used']
Is there a way to insert dates[i] into text[2*j+1] in the way I wanted? Should I even use a for
loop, or is there another way without listing everything in dates as well?