美文网首页Python
[Python]List Functions

[Python]List Functions

作者: Chemizi | 来源:发表于2017-11-30 21:09 被阅读0次

nums = [55, 44, 33, 22, 11]

if all([i > 5 for i in nums]):

  print("All larger than 5")

if any([i % 2 == 0 for i in nums]):

  print("At least one is even")

for v in enumerate(nums):

  print(v)

>>>

All larger than 5

At least one is even

(0, 55)

(1, 44)

(2, 33)

(3, 22)

(4, 11)

>>>

相关文章

网友评论

    本文标题:[Python]List Functions

    本文链接:https://www.haomeiwen.com/subject/ceubbxtx.html