Count how many values in a list that satisfy certain condition

前端 未结 7 1425
醉话见心
醉话见心 2021-01-11 13:50

I have the following list,

mylist = [\'0.976850566018849\',
 \'1.01711066941038\',
 \'0.95545901267938\',
 \'1.13665822176679\',
 \'1.21770587184811\',
 \'1.         


        
7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 14:07

    by using list comprehension

    >>> len([i for i in mylist if float(i) >= 1.3])
    

提交回复
热议问题