I have encountered an error in attempting to clean data from a list.
This Code:
priceList = ['$301,000', '','3 days', '$33,333', '', '2 days', '$40,000', '6 days']
for i in priceList:
if not "$" in i:
priceList.remove(i)
Returns this output:
['$301,000', '3 days', '$33,333', '2 days', '$40,000']
Instead of this:
['$301,000', '$33,333', '$40,000']
Note the blank strings ( ' ' ) in the original list. Though these are removed as expected, the proceeding 'days' values are consequently skipped (the only days value ('6 Days') removed as expected does not have a preceding blank string.)
I have tried various methods to no avail.