I want to return a list of strings, as shown below:
def get_regions():
normalized_regions = []
regions = [
"auckland"
"bay of plenty"
"canterbury"
"gisborne"
"hawkes bay"
"manawatu-whanganui"
"marlborough"
"northland"
"otago"
"southland"
"taranaki"
"tasman"
"waikato"
"wellington"
"west coast"
]
for r in regions:
normalized_regions.append(normalize_location(r))
return normalized_regions
normalize_location()
is a function that converts the string to lowercase and removes unnecessary white spaces.
I don't understand why append()
is concatenating the elements as single string instead of adding them to the list? Please see the screenshot below: