python - 有没有办法根据列表中的所有数字检查数字?

标签 python list python-2.7

我想知道您是否可以检查一个数字与列表中的所有数字,例如:

if n % mylist == 0:
    print "Not Prime"

如果您想知道,这是 this question 的延续,我希望没有关于问题频率的任何规则......:/

最佳答案

if any(n % x == 0 for x in mylist):
    print "Not Prime"

关于python - 有没有办法根据列表中的所有数字检查数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11630004/

相关文章:

python - Tensorflow GPU OOM 错误

python - Tensorflow GetNext() 失败,因为迭代器尚未初始化

python - pyconfig-64.h : No such file or directory

python - 累积总和和结转 - 用 Pandas 矢量化

python - 是否有一个 django 管理小部件用于使用内联 through_model 添加多个外键

javascript - 使用 Gulp 时如何将 React 设置为生产模式

java - 作业帮助 : List Constructors & Exceptions

python - 替换列表中的元素

c# - 从 System.Collections.Generic.List c# 中选择 x 个元素

python - 如何使用 python 2.7 导出带标题的 CSV 文件