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.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

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

Result

python language techstudy.org

     





Related Topics




Popular Posts