首页 > 编程语言 > 详细

python函数练习题2

时间:2020-03-07 13:15:12      阅读:68      评论:0      收藏:0      [点我收藏+]

城市名:编写一个名为 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

 

python函数练习题2

原文:https://www.cnblogs.com/show530/p/12433323.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!