输出列表为字符串,并在最后一个值前加上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))
原文地址:https://www.cnblogs.com/chenxi188/p/9915212.html