Challenge: Deduplicate a Customer List
Swipe to start coding
You are given a list of customer records that contains duplicate entries. Each customer is represented as a dictionary with two fields:
name— the customer's full name;email— the email address provided by the customer.
Your goal is to remove duplicate records using a simple matching rule.
Follow these steps:
- Two records are considered duplicates if their
emailfields match exactly. - Create an empty dictionary named
unique_customers, where keys are email addresses and values are customer dictionaries. - Loop through the input list
customersand add only the first occurrence of each email tounique_customers. - Store the deduplicated list in a new variable named
deduplicated_list, which should contain only the unique customer dictionaries (values ofunique_customers).
Make sure both unique_customers and deduplicated_list are declared and contain the correct deduplicated data.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Großartig!
Completion Rate verbessert auf 8.33
Challenge: Deduplicate a Customer List
Swipe um das Menü anzuzeigen
Swipe to start coding
You are given a list of customer records that contains duplicate entries. Each customer is represented as a dictionary with two fields:
name— the customer's full name;email— the email address provided by the customer.
Your goal is to remove duplicate records using a simple matching rule.
Follow these steps:
- Two records are considered duplicates if their
emailfields match exactly. - Create an empty dictionary named
unique_customers, where keys are email addresses and values are customer dictionaries. - Loop through the input list
customersand add only the first occurrence of each email tounique_customers. - Store the deduplicated list in a new variable named
deduplicated_list, which should contain only the unique customer dictionaries (values ofunique_customers).
Make sure both unique_customers and deduplicated_list are declared and contain the correct deduplicated data.
Lösung
Danke für Ihr Feedback!
single