How to remove all not float numbers and duplicates from list
list, python
Solution
Use a set to remove duplicates, then remove anything else you don't want:
import re
result = set(['17.99', '0.0', '26.95', '26.95', '17.99', 'None', '0.0'])
result = [item for item in result if re.match('\d+\.\d+$', item)]
result = [item for item in result if float(item) != 0.0]
Problem
I have such list: ``` setter_maping = ['14.99', '0.0', '226.95', '0.0', '14.99', 'None', '0.0'] ``` How can I get such list (to remove all duplicates, zeros, Nones... in one word : to remove all what is not float number like 22.22 or 15.66 etc, if I will have there 0.0, or any thing that is not compatible with pattern of number.number (11.1 , 11.11) such value should be deleted): ``` result = ['14.99', '226.95'] ``` I have done simple: ``` kick_off = ['None', '0.0'] [mapped_prices.remove(i) for i in set_map if i in kick_off] ``` But how to produce more unified pattern for removing wrong values? Can regex provide me solution? which regex will solve this? I have no experience with this module