Python: Create a new list from a list when a certain condition is met

谁说胖子不能爱 提交于 2019-11-28 23:43:40
g.d.d.c

Sorry, realized you wanted length, 9, not length 9 or greater.

newlist = [word for word in words if len(word) == 9]

Try:

newlist = []
for item in resultVital:
    if len(item) == 9:
        newlist.append(item)
Brian McFarland

try this:

newlist = [word for word in words if len(word) == 9]

Try this:

list= [list_word for list_word in words if len(list_word) == 1]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!