52
Question Write a method COUNTNOW(PLACES) to find and display those place names in which there are more than 5 characters after storing the name of places in a dictionary. For example, if the dictionary PLACES contains:
{'1': "DELHI", '2': "LONDON", '3': "PARIS", '4': "NEW YORK", '5': "DUBAI"}
The following output should be displayed:
LONDON
NEW YORK
PLACES = {1: "Delhi", 2: "London", 3: "Paris", 4: "New York", 5: "Doha"}
def countNow(PLACES):
for place in PLACES.values():
if len(place) > 5:
print(place.upper())
countNow(PLACES)LONDON
NEW YORK
PLACES
=
{
1
:
"Delhi"
,
2
:
"London"
,
3
:
"Paris"
,
4
:
"New York"
,
5
:
"Doha"
}
def
countNow
(
PLACES
):
for
place
in
PLACES
.
values
():
if
len
(
place
)
>
5
:
print
(
place
.
upper
())
countNow
(
PLACES
)
Output
LONDON
NEW YORK