line1 = " The median income for a household in the city was $64,411, and the median income for a family was $78,940. The per capita income for the city was $22,466. About 4.3% of families and 5.9% of the population were below the poverty line, including 7.0% of those under age 18 and 12.3% of those age 65 or over."
line2 = " The median income for a household in the city was $31,893, and the median income for a family was $38,508. Males had a median income of $30,076 versus $20,275 for females. The per capita income for the city was $16,336. About 14.1% of families and 16.7% of the population were below the poverty line, including 21.8% of those under age 18 and 21.0% of those age 65 or over."
expected output:
household median income: $64,411
family median income: $78,940
per capital income: $22,466
[householdIncome, familyIncome, perCapitalIncome] = re.findall("\d+,\d+",line1)
line1 works well. line2:
ValueError: too many values to unpack (expected 3)
The main obj is how to identify the 1st number/value after locate the key word.
some lines they do not have the per capital income, I can accept it as ""