Extract City Code from Property ID
Extract City Code from Property ID
EasyStrings0% accepted
Priya works at MagicBricks' Bangalore office. Each property listing has an ID like 'MH-2024-Mumbai-5678' where the third segment is the city name. Extract the city name from property IDs to categorize listings.
Approach
Given a property ID string formatted as 'STATE-YEAR-CITY-NUMBER' with hyphens as delimiters, extract and return the CITY portion.
Input
MH-2024-Mumbai-5678
Output
Mumbai
More Strings problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards