小编Tom*_*nda的帖子

如何计算列表中一定范围内的元素?

我需要计算字符串中有多少数字的值大于或等于 25 且小于或等于 50

numbers = [25, 24, 26, 45, 25, 23, 50, 51]

#  'count' should be 5 
count = 0
Run Code Online (Sandbox Code Playgroud)
# I need to filter all numbers and only numbers what are higher than 25 can stay 

numbers = [25, 24, 26, 45, 25, 23, 50, 51]

#  'filtered' should be equal to [26, 45, 50, 51]
filtered = []
Run Code Online (Sandbox Code Playgroud)

python python-3.x jupyter-notebook jupyter-lab

2
推荐指数
2
解决办法
3384
查看次数