List Comprehensions and Lambda Functions 3 of 13 · Deleting Dictionary Keys

Screen Link:

My Code:

Replace this line with your code

hn_clean = # Creating an empty list, hn_clean to store the cleaned data set and assign it to a variable, hn_clean

for row in hn:
cleaned_rows = row[0:]
def jprint(obj2):
text2 = json.dumps(obj2, sort_keys = True, indent = 4)
print(text2)
cleaned_rows = row[0:]
jprint(cleaned_rows)

def del_key(dict_, key):
    modified_dict = dict_.copy()
    del modified_dict[key]
    return modified_dict
cleaned_rows = del_key(cleaned_rows, 'createdAtI')
jprint(cleaned_rows)
hn_clean.append(cleaned_rows)

print(hn_clean)

What actually happened:

Do I still need to use this part of the code for this exercise?:

def jprint(obj):
    # Create a formatted string of the Python JSON object
    text = json.dumps(obj, sort_keys = True, indent = 4)
    print(text)

This is the correct answer for this exercise:


Thank you
-Salem

Hey! Yes, you still need to use that part of code for your exercise. Don’t delete any previous code written in the exercise for a future reference.

1 Like