This is another probably very simple question, but I haven’t been able to find anything to fix it so far.
I’m trying to add 14 days to some dates in a list of 2000 lists (each list is ['number1','number2','Day Month Year']) and put the new date as a value at the end of each list (i.e. each list becomes ['number1', 'number2', 'Day Month Year', 'Day Month Year']).
What I’ve got so far is:
from datetime import timedelta
listf=[]
z=range(len(hinfo))
for i in z:
datetime.datetime.strptime(hinfo[i][2],'%d %b %y')
listf.append(hinfo[i][2]+timedelta(days=14))
But this brings up the error ‘ValueError: unconverted data remains: 01’. All of the dates in the list should be fine so I can’t figure out why the errors coming up.
Forgive a beginner if it’s just a simple mistake 🙂
Thanks!
The correct code that appends the new date to the original list, as you specified in your question:
For me, this prints
[['C148', 'W29', '08 August 2001', '22 August 2001'], ['Q964', 'R72', '21 May 20, which is what you wanted, if I understood your question correctly.03', '04 June 2003']]
If you get an error, it is most likely that the input is not as you said, or think it is.