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:
Original numbers in the list: [-10, 10, 15, -56]
Positive numbers in the list: [10, 15]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used python 3.7 compiler for debugging purpose.
Result:
Original numbers in the list: [-10, 10, 15, -56]
Positive numbers in the list: [10, 15]
need an explanation for this answer? contact us directly to get an explanation for this answer