1

Using a list comprehension

myList=[-2,-1,0,1,2,3,1,2,3]
result=[each for each in myList if each>0] 

Results to:

[1,2,3,1,2,3]

How to avoid the duplicated values in returned list?

alphanumeric
  • 15,954
  • 55
  • 201
  • 355

0 Answers0