Python Forum
Making lists using itertools and eliminating duplicates.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making lists using itertools and eliminating duplicates.
#3
You use bbcode "python" tags around your code in the post to display properly. You can click the Python logo button above the editor to insert them automatically.

If you just need the size of the set, you don't have to convert it to a list. len() works just fine on sets, so

print(len(set(entry)))
should be sufficient. If you don't need the ordering, you could just create non_dup as a set in the first place and then add objects to it (rather than append them).
Reply


Messages In This Thread
RE: Making lists using itertools and eliminating duplicates. - by bowlofred - Oct-26-2020, 05:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove partial duplicates from csv ledgreve 0 790 Dec-12-2022, 04:21 PM
Last Post: ledgreve
  itertools and amazing speed Pedroski55 8 2,060 Nov-11-2022, 01:20 PM
Last Post: Gribouillis
  Problem : Count the number of Duplicates NeedHelpPython 3 4,386 Dec-16-2021, 06:53 AM
Last Post: Gribouillis
  Eliminating error in Python update-alternatives Led_Zeppelin 2 3,003 Apr-14-2021, 12:49 PM
Last Post: Led_Zeppelin
  Removal of duplicates teebee891 1 1,797 Feb-01-2021, 12:06 PM
Last Post: jefsummers
  eliminating letters when typed in python window deebo 0 1,742 Jan-05-2021, 09:26 AM
Last Post: deebo
  What happens to a <itertools.permutations object at 0x7fe3cc66af68> after it is read? Pedroski55 3 2,409 Nov-29-2020, 08:35 AM
Last Post: DeaD_EyE
  Displaying duplicates in dictionary lokesh 2 1,998 Oct-15-2020, 08:07 AM
Last Post: DeaD_EyE
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,379 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Python3 itertools.groupby printing the key august 1 2,093 Aug-17-2020, 05:46 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020