title不能用于列表

def show_physicist(names_list):
print(names_list.title())

physicist_names = [‘einstein’,‘newton’,‘hawking’]
show_physicist(physicist_names)
AttributeError:‘list’ object has no attritube title

修改后的代码
def show_physicist(names_list):
print(str(names_list).title())

physicist_names = [‘einstein’,‘newton’,‘hawking’]
show_physicist(physicist_names)

你可能感兴趣的:(title不能用于列表)