Cities & Population: The program must accept the name and population of N cities as the input. The program print the totalpopulation in the given N cities as the output. Then the program must print the name and population of eachcity separated by a colon as the output. Please fill in the blanks with code so that the program runs successfully.
Example Input/Output 1:
Input:
3
KKTCity 19000
URCity 81000
MCCity 21000
Output:
121000
KKTCity:19000
URCity:81000
MCCity:21000
Explanation:
Here N = 3 and the totalpopulation in the given 3 cities is 121000.
Hence the output is
121000
KKTCity:19000
URCity:81000
MCCity:21000
Example Input/Output 2:
Input:
6
MNOCity 25000
BBCity 64250
KPKCity 49999
ABCCity 33750
RRCity 9200
AKKCity 13600
Output:
195799
MNOCity:25000
BBCity:64250
KPKCity:49999
ABCCity:33750
RRCity:9200
AKKCity:13600
class City:
__totalPopulation = 0
def __init__(self, name, population):
self.name = name
self.population = population
City._City__totalPopulation+=population
def __str__(self):
return self.name+":"+str(self.population)
N = int(input())
cities = []
for ctr in range(N):
name, population = input().split()
cities.append(City(name, int(population)))
print(City._City__totalPopulation)
for city in cities:
print(city)