English

Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES as an argument and displays the names (in uppercase) of the places whose names are longer than 5 characters. - Computer Science (Python)

Advertisements
Advertisements

Question

Write a function countNow (PLACES) in Python, that takes the dictionary, PLACES as an argument and displays the names (in uppercase) of the places whose names are longer than 5 characters.
For example, Consider the following dictionary

PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}

The output should be:

  • LONDON
  • NEW YORK
Answer in Brief
Advertisements

Solution

PLACES={1:"Delhi",2: "London", 3: "Paris", 4: "New York",5:"Dubai"}
def countNow (PLACES) :
     for place in PLACES. values ():
          if len (place) > 5:
              print (place. upper ())
countNow (PLACES)
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×