Pull Rupee Amounts from Text

Medium ⏱ 12 min 57% acceptance ★★★★☆ 4.2
Write prices(text) extracting every amount written as followed by digits with optional comma groups and optional decimals (e.g. ₹1,299.50), returned as floats with commas removed.

Examples

Example 1
Input
prices('was ₹1,299 now ₹999.50')
Output
[1299.0, 999.5]
Explanation

Commas stripped, decimals preserved.

Constraints

  • Handle comma-grouped thousands.
  • Return floats.

Topics

Regular Expressionsnumeric capture

Companies

FlipkartMyntraPaytm

Hints

Hint 1

Pattern: ₹([\d,]+(?:\.\d+)?).

Hint 2

float(m.replace(',', '')) per match.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.