my code is not capturing the amount after comma in a pound amount, or if the amount comes after a space.
Here is what I have so far:
finalcontent=' £2,500 and also £ 1200 and also £ 7,645 and finally £8888 and london'
price=[]
# -*- coding: utf-8 -*-
import sys
import re
new = re.findall(r'[£]{1}\d+\.?\d{0,2}',finalcontent,re.UNICODE)
if len(new) != 0:
for prices in new:
dumistring=str(prices)
price.append(re.sub("[^0-9.]","",dumistring))
for ic in range(0, len(price)):
price[ic] = float(price[ic])
avg_cost = sum(price)/len(price)
pricinglist.append(avg_cost)
output is
price
[2.0, 8888.0]