Python Forum
Converting List of 3 Element Tuple to Dictionary
Thread Rating:
  • 3 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting List of 3 Element Tuple to Dictionary
#5
If you don't have to implement your own Counter, you can use the Counter from the collections module.
As mentioned before, tuples are immutable and hashable objects, which can be used as keys for a dict.

In your case, it's just Counter(your_list).
Btw. you've used list as a name for the list. list is a type and you've overwritten it with your list.
Give it another name.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Converting List of 3 Element Tuple to Dictionary - by DeaD_EyE - Jan-10-2019, 01:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sort a list of dictionaries by the only dictionary key Calab 2 602 Apr-29-2024, 04:38 PM
Last Post: Calab
  element in list detection problem jacksfrustration 5 436 Apr-11-2024, 05:44 PM
Last Post: deanhystad
  using > < for tuple , list,... akbarza 3 512 Feb-05-2024, 01:18 PM
Last Post: deanhystad
  Dictionary in a list bashage 2 594 Dec-27-2023, 04:04 PM
Last Post: deanhystad
  filtering a list of dictionary as per given criteria jss 5 734 Dec-23-2023, 08:47 AM
Last Post: Gribouillis
  Searche each element of each tuple based 3 numbes zinho 8 914 Dec-11-2023, 05:14 PM
Last Post: zinho
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 509 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  list in dicitonary element problem jacksfrustration 3 752 Oct-14-2023, 03:37 PM
Last Post: deanhystad
  Change font in a list or tuple apffal 4 2,729 Jun-16-2023, 02:55 AM
Last Post: schriftartenio
  How to add list to dictionary? Kull_Khan 3 1,036 Apr-04-2023, 08:35 AM
Last Post: ClaytonMorrison

Forum Jump:

User Panel Messages

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