Find positive and negative numbers in list Dry Run in PYTHON

Find positive and negative numbers in list is an interactive PYTHON dry run visualizer from the Lists programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Find positive and negative numbers in list Program Code

# Separate positive and negative numbers
numbers = [15, -3, 28, -7, 0, -12, 45, -9, 33, -21, 10]
print("Original list:", numbers)

positives = []
negatives = []
zeros = 0

for num in numbers:
    if num > 0:
        positives.append(num)
    elif num < 0:
        negatives.append(num)
    else:
        zeros += 1

print(f"\nPositive numbers ({len(positives)}): {positives}")
print(f"Negative numbers ({len(negatives)}): {negatives}")
print(f"Zeros: {zeros}")

View the complete Lists programs page.

Program Console Find positive and negative numbers in list Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.