Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Print all Positive Numbers in a List


This example shows, how to print all positive numbers in a given list . Iteration of each element in the list using for loop and check if number is greater than or equal to 0. If the condition is true print the Positive numbers only.

Example.py
a = [89, -84, 54, 56, -45, -13, 11, 18]

# Iterating through the each number in list
for num in a:
    #Check the condition
    if num >= 0:
        print(num, end=" ")

Output

Positive Numbers in Given List :
89 54 56 11 18

Prev Next