Write a function countletter() that should have a 'for' loop that steps
through the list below and prints the name of the city and the number of
letters in the city's name. You may use the len() function.
citylist = ["Kentucky","New York","LA", "Toronto",
"Boston","District of Columbia"]
city = len(citylist)
ct = 0
for i in citylist:
city = (ne[i])
You don't need to use indices. Just iterate
for loop will yield each city.
def countletter(citylist): for city in citylist: n = len(city) print(city, 'has', n, 'letters.') citylist = ["Kentucky","New York","LA", "Toronto", "Boston","District of Columbia"] countletter(citylist)
Kentucky has 8 letters. New York has 8 letters. LA has 2 letters. Toronto has 7 letters. Boston has 6 letters. District of Columbia has 20 letters.