[Tutor] print date and skip any repeats
Peter Otten
__peter__ at web.de
Wed Sep 17 11:51:47 CEST 2014
questions anon wrote:
> I think this should be simple but I can't find the right commands.
>
> I have a date for each hour for a whole month (and more) and I would like
> to write a loop that prints each date that is different but skips the
> dates that are the same.
>
> for i in date:
> print i and then skip i until different
> print next i and then skip i until different
> etc.
>
>
> Any feedback will be greatly appreciated.
Store the previous date in a variable and then compare it with the current
date. If the current date differs from the previos one print it and update
the previous date.
More information about the Tutor
mailing list