← All Python interview questions

Clean messy city names from a CRM export

EasyStrings & Text CleaningZomatoRazorpay

A CRM export has arrived with inconsistent city names — stray spaces, SHOUTING CAPS and lowercase entries. Before the team can group revenue by city, the values need to be standardised.

Write a function clean_city(name) that returns the city name with leading and trailing whitespace removed and each word capitalised (first letter upper, rest lower).

More Strings & Text Cleaning questions

Practising alone only goes so far — our live cohorts pair Python and Pandas depth with dashboards, agentic analytics projects and mock interviews.

Explore the program