VOOZH about

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

⇱ Python program to count positive and negative numbers in a list - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python program to count positive and negative numbers in a list

Last Updated : 11 Jul, 2025

In this article, we will explore various methods to count positive and negative numbers in a list. The simplest way to do this is by using a loop. This method counts the positive and negative numbers in a list by iterating through each element using for loop.


Output
3
3

Let's explore other different method:

Using filter() Function

filter() function can be used to filter positive and negative numbers and we can count them using len(). It is better than a manual loop since it avoids the explicit creation of new lists during iteration.


Output
3
3

Using List Comprehension

List comprehension provides a more concise way to count positive and negative numbers. It iterate through the list and create new lists based on conditions.


Output
3
3
Comment
Article Tags: