📜  python如何跳过迭代 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:39.096000             🧑  作者: Mango

代码示例1
nums = [7,3,-1,8,-9]
positive_nums = []

for num in nums:
    if num < 0: #skips to the next iteration
        continue
    positive_nums.append(num)
        
print(positive_nums) # 7,3,8