Please post in text mode, not html.

questions anon <questions.a...@gmail.com> Wrote in message:
>
> lastdate=all_the_dates[1]
> onedateperday.append(lastdate)
> print onedateperday
> for date in all_the_dates:
>      if date !=lastdate:
>           lastdate=date
>          onedateperday.append(lastdate)

There are a number of things you don't explicitly specify.  But if
 you require the dates in the output list to be in the same order
 as the original list, you have a bug in using element [1]. You
 should be using element zero, or more simply:

lastdate=None
for date in all_the_dates:
    if date !=lastdate:
        onedateperday.append(date)
        lastdate=date

But if you specified a bit more, even simpler answers are possible. 

For example,  if output order doesn't matter, try:
     onedateperday = list (set (all_the_dates))

If output order matters, but the desired order is sorted,
    onedateperday = sorted ( list (set (all_the_dates)))

Other approaches are possible using library functions,  but this
 should be enough.



-- 
DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to