![](/img/trans.png)
[英]How to make '?' equal a number, so when i go through a list. It will count it as a zero. (Python)
[英]How to I detect if each number in the list is equal to or below zero?
all()
检查数组中的所有项目是否为真,然后返回 boolean。 要检查列表中的数字是否小于零,您可以执行以下操作: all([i>=0 for i in [-1,-2,-3,3]])
我会做
if max(test_3) <= 0:
print("all negative")
else:
print("there is a positive")
这对我来说似乎更明确,您希望最大值为 0 或更小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.