Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Searching in the list
#3
Identical code with better names and as a function.

from collections import defaultdict


def calc(data):
    results = defaultdict(complex)
    for value, symbols, mysterious_number in data:
        results[symbols] += value ** 2
    return results
quest likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
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,542 Mar-08-2019, 07:58 PM
Last Post: Larz60+
  Searching through a list of dictionaries with a condition. Mr_Keystrokes 11 5,432 Oct-05-2018, 11:03 AM
Last Post: Mr_Keystrokes
  searching within specified variable list milo204 2 49,602 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