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
  • 17,967
  • 64
  • 244
  • 392

0 Answers0