#coding:gbk#8-6城市名defcity_country(name,country):"""返回城市和国家"""
x = name +","+ country
return x.title()
s = city_country('santiago','chile')print(s)
j = city_country('shanghai','china')print(j)
u = city_country('wuhan','china')print(u)#8-7专辑defmake_album(singer,name):"""返回字典"""
album ={'singer':singer,'album':name}return album
a = make_album('taylor','speak now')print(a)
b = make_album('Taylor','1989')print(b)
c = make_album('TS','folklore')print(c)#8-8用户的专辑whileTrue:print("\nPlease tell me your favorite:")print("(enter 'q' at any time to quit)")
singer1 =input("请输入歌手名字:")if singer1 =='q':break
name2 =input("请输入专辑名称:")if name2 =='q':break
formatted = make_album(singer1,name2)print(formatted)
Python编程:从入门到实践第八章练习8.3#coding:gbk#8-6城市名def city_country(name,country): """返回城市和国家""" x = name + "," + country return x.title() s = city_country('santiago','chile')print(s)j = city_country('shanghai','china')print(j)u = city_country('wuhan','