list. entry will be the list created for the second dictionary, and so on.) eated for the first dictionary; the second entry Each entry in the returned list will contain a list of values from that dictionary. The second parameter's entries specify the keys whose values should be added to this list. The order of these values must parallel the order of the keys in the second parameter. (So first will be the value associated with the second parameter's first entry, second will be the value associated with the second parameter's second entry, and so on.) You SHOULD assume that every dictionary will contain all of the keys from the first parameter. Python creates a new list only when a variable is assigned a list literal. You MUST include the statement initializing the variable to which the dictionary's values are added INSIDE the for-loop iterating through the first parameter. As an example, if this were a function call: list_gen ([{'Used Key': 'Data', 'Unused Keys': 'More Data'}], ['Used Key']) the expected return value would be: [ ['Data']] As an second example, if this were a function call: list_gen ([{'Hint': 'Length 2 Not Required', 'Num': 8675309), {'Num': 1, 'Hint': 'Use 1st param order'}], ['Hint', 'Num']) the expected return value would be: [['Length 2 Not Required', 8675309], ['Use 1st param order', 1] I Page 3/ +
list. entry will be the list created for the second dictionary, and so on.) eated for the first dictionary; the second entry Each entry in the returned list will contain a list of values from that dictionary. The second parameter's entries specify the keys whose values should be added to this list. The order of these values must parallel the order of the keys in the second parameter. (So first will be the value associated with the second parameter's first entry, second will be the value associated with the second parameter's second entry, and so on.) You SHOULD assume that every dictionary will contain all of the keys from the first parameter. Python creates a new list only when a variable is assigned a list literal. You MUST include the statement initializing the variable to which the dictionary's values are added INSIDE the for-loop iterating through the first parameter. As an example, if this were a function call: list_gen ([{'Used Key': 'Data', 'Unused Keys': 'More Data'}], ['Used Key']) the expected return value would be: [ ['Data']] As an second example, if this were a function call: list_gen ([{'Hint': 'Length 2 Not Required', 'Num': 8675309), {'Num': 1, 'Hint': 'Use 1st param order'}], ['Hint', 'Num']) the expected return value would be: [['Length 2 Not Required', 8675309], ['Use 1st param order', 1] I Page 3/ +
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
so im having an issue writing this code. the question, plus the errors are shared in screenshots. please, please, if an expert can help me correct this, id immensely appreciate it
def list_gen(d, l):
result = []
for k in d:
x = []
sorted_dict = dict()
sorted_list = list((i, k[i]) for i in l)
for i in sorted_list:
sorted_dict.setdefault(i[0], i[1])
for key, value in sorted_dict.items():
if key in l:
x.append(value)
result.append(x)
return result
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education