generate functionWed, 01 Mar 2023

A list of city names is entered in one line separated by a space. Determine that all cities in this list are more than 5 characters long. Implement the program using a while loop and a break statement. Print YES if the condition is met and NO otherwise.

def city_5(a): if len(a) > 5: return "Yes" else: return "No" a = input("Enter cities separated by a space: ").split() i = 0 while i < len(a): print(city_5(a[i])) i += 1

Questions about programming?Chat with your personal AI assistant