Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Searching in the list
#2
You could use a dictionary
from collections import defaultdict
d = defaultdict(complex)
for c, name, n in mylist:
    d[name] += c * c

print(d)
quest likes this post
Reply


Messages In This Thread
Searching in the list - by quest - Mar-02-2022, 05:56 AM
RE: Searching in the list - by Gribouillis - Mar-02-2022, 06:47 AM
RE: Searching in the list - by quest - Mar-02-2022, 10:30 AM
RE: Searching in the list - by DeaD_EyE - Mar-02-2022, 09:45 AM
RE: Searching in the list - by Gribouillis - Mar-02-2022, 09:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Linear search/searching for a word in a file/list kietrichards 3 3,540 Mar-08-2019, 07:58 PM
Last Post: Larz60+
  Searching through a list of dictionaries with a condition. Mr_Keystrokes 11 5,431 Oct-05-2018, 11:03 AM
Last Post: Mr_Keystrokes
  searching within specified variable list milo204 2 49,572 Feb-13-2018, 09:43 AM
Last Post: milo204
  Searching for items within a list Yobby 9 6,356 Jul-03-2017, 05:53 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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