Combine the list returned by `re.findall()`

This question already has an answer here:

  • Difference between append vs. extend list methods in Python 22 answers

  • 尝试reduce(sum, line)

    def extractDollar(line): 
            global mainList
            temp=[]
    
            #lowercasing all the string
            line=line.lower()
    
            #storing all word starting with $ in a line in temp
            #then adding that  to existing list mainList
            #to form a single list and removing empty value
            temp= re.findall(r'$w+',line)
    
            mainList=mainList+[j for i in zip(mainList,temp) for j in i]
            mainList= filter(None, mainList)
    
            return reduce(sum,line)
    
    链接地址: http://www.djcxy.com/p/22560.html

    上一篇: Python列表.extend方法将字符串分解为字符

    下一篇: 合并由`re.findall()`返回的列表