例如:
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)