VOOZH about

URL: https://www.geeksforgeeks.org/python/python-program-to-print-positive-numbers-in-a-list/

⇱ Python Program to Print Positive Numbers in a List - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python Program to Print Positive Numbers in a List

Last Updated : 28 Oct, 2025

Given a list of numbers, the task is to print all positive numbers in the list. A positive number is any number greater than 0.

For example:

a = [-10, 15, 0, 20, -5, 30, -2]
Positive numbers = 15, 20, 30

Using NumPy

This method uses NumPy arrays to efficiently extract all positive numbers at once using boolean indexing.


Output
[15 20 30]

Using List Comprehension

This method creates a new list of positive numbers using list comprehension in one line by checking each element of the original list.


Output
[15, 20, 30]

Using filter() Function

The filter() function can select elements from the list that meet a given condition. We use it with a lambda function to filter positive numbers.


Output
[15, 20, 30]

Using Loop

The most basic method for printing positive numbers is to use a for loop to iterate through the list and check each element.


Output
15
20
30
Comment
Article Tags: