Write a Python program to filter the positive numbers from a list

Introduction

Write a Python program to filter the positive numbers from a list. I have used python 3.7 compiler for debugging purpose.

nums = [-10, 10, 15, -56]
print("Original numbers in the list: ",nums)
Pos_nums = list(filter(lambda x: x >0, nums))
print("Positive numbers in the list: ",Pos_nums)

Result

Write a Python program to filter the positive numbers from a list
Write a Python program to filter the positive numbers from a list

Leave a Comment