Exercise 1 solution import re t = "Sales: 1234567 units, 89 units, 1000000 units, 999 units" print(re.sub(r"(?<=\d)(?=(?:\d{3})+\b)", ",", t)) # Sales: 1,234,567 units, 89 units, 1,000,000 units, 999 units (All lines were run and printed exactly what is shown.) Explanation: the pattern matches an empty position that (1) has a digit before it and (2) is followed by one or more complete groups of three digits that end at a word boundary. Both checks are lookarounds, so nothing is consumed and sub only inserts a comma. 89 and 999 are unchanged because the only positions with a digit before them leave fewer than three digits (or a leftover that is not a multiple of three) before the end of the number, so condition (2) fails everywhere inside them.