Exercise 1 solution import re log = "disk 87% full, cpu 5%, mem 100%" print(re.findall(r"\d+(?=%)", log)) # ['87', '5', '100'] print(re.findall(r"\d+%", log)) # ['87%', '5%', '100%'] (Both lines were run and printed exactly the lists shown.) Explanation: \d+ takes one or more digits. In the first pattern, (?=%) is a lookahead: it requires a percent sign next but does not consume it, so the sign is not part of the result. In the second, the % is an ordinary part of the pattern, so it is included.