一、允许任意输入list内容,间隔加逗号和空格,最后一个前方加and字样:
def m(b):
for i in range(len(b)):
if (i==(len(b)-1)):
print("\b\b and", b[i])
else:
print(b[i] + ",", end=' ')
a = ['apples', 'bananas', 'tofu', 'cats']
c = []
print("give an list content :")
while True:
fruit = input()
if fruit == "":
break
c = c + [fruit]
if (len(c)>0):
m(c)
else:
m(a)