"""练习一:循环打印晚餐嘉宾 """class Dinner: def Guest_list(self): guest_list = ['zhou', 'wu', 'zheng', 'wang'] return guest_list def sort_list(self, guest_list): guest_list.sort() print('当前晚宴嘉宾名单:' + str(guest_lis
"""class Dinner:
def Guest_list(self):
guest_list = ['zhou', 'wu', 'zheng', 'wang']
return guest_list
def sort_list(self, guest_list):
guest_list.sort()
print('当前晚宴嘉宾名单:' + str(guest_list))
def print_list(self, guest_list):
for i in range(len(guest_list)):
print('欢迎' + guest_list[i] + '于今晚参加晚宴!')
print('\n')
if __name__ == '__main__':
dinner = Dinner()
guest_list = dinner.Guest_list()
dinner.sort_list(guest_list)
dinner.print_list(guest_list)