python函数练习题2

城市名:编写一个名为 city_country()的函数,它接受城市的名称及其所属的

国家。这个函数应返回一个格式类似于下面这样的字符串:

------------------------------
"Santiago, Chile"

------------------------------

def city_country(city_name,country_name):
    city_country_name = city_name+'  '+country_name
    return city_country_name

i=0
while i<3:
    ci_name = input("Please enter the city name: ")
    co_name = input("Please enter the country name: ")
    ci_co_name = city_country(ci_name,co_name)
    print(ci_co_name.title())
    i+=1
    while i==3:
        chioce = input("You have entered it three times. Would you like to try to enter new three times(y or n)? ")
        if chioce == "y":
            i=0
        else:
            print("Welcome to play next time! Bye!")
            break

猜你喜欢

转载自www.cnblogs.com/show530/p/12433323.html