0

Python inheritance

For the odds method,how to remove the items from the list that’s not odds and return the original list only has the odd numbers?

4th Oct 2018, 7:44 AM
Vicky Hu
Vicky Hu - avatar
2 Answers
+ 4
list(filter(lambda x: x%2==1, numlist))
4th Oct 2018, 9:36 AM
Flandre Scarlet
Flandre Scarlet - avatar
0
another method with generator list(p for p in numlist if p%2)
6th Oct 2018, 8:32 AM
Flandre Scarlet
Flandre Scarlet - avatar