We take a 6-digit pincode as input from the user and validate it before processing. By splitting the first digit, first two digits, and first three digits, we identify the Region, Sub-region, and District. This way, anyone can find the exact location details of any pincode.
regions={1:"Delhi",2:"Uttar Pradesh & Uttarakhand",3:"Rajasthan & Gujarat",4:"Maharashtra",5:"Andhra Pradesh & Telangana",6:"Tamil Nadu & Kerala",7:"West Bengal & North East",8:"Bihar & Jharkhand",9:"Army Postal Service"}sub_regions={11:"Delhi Region",40:"Mumbai Region",60:"Chennai Region",70:"Kolkata Region"}districts={110:"Delhi",111:"Delhi (North)",112:"Delhi (South)",400:"Mumbai",401:"Mumbai (Suburban)",402:"Mumbai (West)",600:"Chennai",601:"Tiruvallur",602:"Kanchipuram",700:"Kolkata",701:"Kolkata (North)",702:"Kolkata (South)"}defget_pincode_details(pincode):ifnotpincode.isdigit()orlen(pincode)!=6:print("Invalid pincode. Enter exactly 6 digits.")returnnum=int(pincode)first_digit=num//100000first_two=num//10000first_three=num//1000print("Region: ",regions.get(first_digit,"Unknown"))print("Sub-region: ",sub_regions.get(first_two,"Unknown"))print("District: ",districts.get(first_three,"Unknown"))pincode=input("Enter Pincode: ").strip()get_pincode_details(pincode)
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)