输出列表为字符串,并在最后一个值前加上and 4.10.1

逗号代码:

1 def test4(lis):
2     str1=''
3     for i in range(len(lis)-1):
4         str1+=(str(val[i])+', ')
5     str1+=('and '+str(lis[-1]))
6     return str1
7 
8 spam=['b0','b1','b2','b3']
9 print (test4(spam))

 

posted @ 2018-11-06 14:46  晨光曦微  阅读(207)  评论(0编辑  收藏  举报