练习8-6:城市名 编写一个名为city_country() 的函数,它接受城市的
名称及其所属的国家。这个函数应返回一个格式类似于下面的字符串:
"Santiago, Chile"
至少使用三个城市国家对来调用这个函数,并打印它返回的值。
def city_country(city_name, country_name):
in_city_country = f"\n{city_name}, {country_name}"
return in_city_country.title()
city_and_country = city_country('shanghai', 'china')
city_and_country1 = city_country('guangzhou', 'china')
city_and_country2 = city_country('beijing', 'china')
print(city_and_country, city_and_country1, city_and_country2)
Shanghai, China
Guangzhou, China
Beijing, China
进程已结束,退出代码0