For items in a dictonary, split the name of one item, add and remove some info python
<p>I have a dictionary with this info: </p>

<pre><code>x = {Country:{City:Population},.....}
</code></pre>

<p>but City name is now like: <code>Country_City_Neighbourhood_Population</code> (for some reason). I need to remove all the information and just keep the City and Neighbourhood like this: <code>CityNeighbourhood</code>.</p>

<p>I did this:</p>

<pre><code>for country in x:
 for city, pop in x[country].iteritems():
  isCountry = city.split("_").count("Ecuador")
  if isCountry &gt; 0:
   city1 = city.split("_")
   city1.remove("Ecuador")
   city2 = city1[0:-1]
   city3 = ""
   for i in range(len(city2)-1):
    city3 = city3 + city2[i]
</code></pre>

<p>but I didn't obtain any reasonable result. </p>
