2 votes
Accepted

Iterate over a list of dicts and get key value pair of specific keys

I think using a dictionary comprehension is probably easiest. I think this is the sort of thing you are trying to get? data = [{'symbol': 'ZYME', 'exchange': 'NYS', 'name': 'Zymeworks Inc.', 'date': ...
curiouskiwi's user avatar
  • 18.7k
1 vote
Accepted

Problem taking a SUM with SQL to python

From the CS50 Library for Python doc for execute Returns for SELECTs, a list of dict objects, each of which represents a row in the result set; for INSERTs, the primary key of a newly inserted row (...
DinoCoderSaurus's user avatar
1 vote
Accepted

pset7 "index" - using SQL SUM adds a parenthesis to returned dict strings

You can use AS to rename a field, this is especially useful if you join multiple tables and return fields from several of them, or when using aggregate functions as you do here. Like "SELECT buy....
Blauelf's user avatar
  • 20.9k
1 vote
Accepted

Question about python dict syntax, how to past from one dict variable to another?

'share' a string variable that holds the values of an item in 'sharesOwned' so it is not a dictionary. If you took the square brackets away: share = shareNow['name'] This would allow the assignment. ...
Ryan McCauley's user avatar
1 vote
Accepted

For loop help in python

In a dictionary the indices use strings, whereas lists are indexed using integers beginning with 0. The error: TypeError: list indices must be integers, not dict is because you are using string as ...
Ryan McCauley's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible