【Python 3.7】城市名:编写一个名为 city

    xiaoxiao2022-07-13  157

    【Python 3.7】城市名:编写一个名为 city_country() 的函数,它接受城市的名称及其所属的 国家。这个函数应返回一个格式类似于下面这样的字符串: “Santiago, Chile”

    题目:城市名:编写一个名为 city_country() 的函数,它接受城市的名称及其所属的 国家。这个函数应返回一个格式类似于下面这样的字符串: “Santiago, Chile” 至少使用三个城市国家对调用这个函数,并打印它返回的值。

    我选的城市是:北京,上海,沈阳。 程序为:

    def city_country(city_name,country_name): print(city_name.title()+','+country_name.title()) city_country('Beijing','china') city_country('shanghai','china') city_country('shenyang','china')

    结果为:

    Beijing,China Shanghai,China Shenyang,China
    最新回复(0)