Question #267452

write a program in Python to store the name of five cities list create a function search name to search city using Linear search if the required name was and name it is not available the function should return -1

Expert's answer

cities = ['Moscow', 'New York', 'Ekaterinburg', 'Tokyo', 'Berlin']


def search_city(name):
    for city in cities:
        if city.lower() == name.lower():
            return True
    return -1
    
name = input()
print(search_city(name))
LATEST TUTORIALS
APPROVED BY CLIENTS