[Tutor] Duplicate items in list

Manprit Singh manpritsinghece at gmail.com
Sat Oct 10 06:27:16 EDT 2020


Thanks a lot sir .

Regards
Manprit Singh

On Sat, Oct 10, 2020 at 3:53 PM Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 10/10/2020 05:41, navin ray wrote:
>
> > provide solution to the same problem using very simple code (I.e without
> > using any built in functions) so that even a noob like me could
> understand.
>
> It is almost impossible to write code without using the
> built in functions. They are part of the language without
> which almost every task becomes impossible.
>
> If however, you mean without using the standard library - which
> is also part of the language, albeit not part of its
> definition -  then that is possible and may help you understand
> the principle. But you should understand that not using the
> library would be considered bad practice and could, in
> an interview situation, be considered a fail.
>
> > I am sorry if my suggestions is not relevant to the mailing list.
>
> It is completely relevant, and helping people understand basic
> programming principles is part of what this list is for.
>
> IMHO The best solution posted so far that does not use the
> library is the one by Dennis Beiber (slightly modified for
> clarity):
>
> data = [3, 3, 5, 5, 5, 6, 6, 6, 5, 9, 3, 3, 3, 5, 5]
> previous = None
> for item in data:
>     if item != previous:
>         print(item)
>         previous = item
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list