乱写的代码
噗呲~
问完名字说哈罗
哈喽说完还有否
选择图表看一看
看完也可退出咯
def greet_user(username):
print ('hello!' + username.title() + '!')
names = []
active = True
while active:
name = input('what is your name? '
'\nOr you can choose quit to quit and the chart to check the chart. ')
names.append(name)
if name == 'quit':
print ('already quit')
active = False
elif name == 'chart':
names.remove('chart')
print (names)
else:
greet_user(name)
小问题:打完chart本来还会在列表里会有chart,很难受,我不会;
但我是个大聪明,我直接remove咯(啊~好冗余)
下面是运行结果: