August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 26 | Let’s Vote |
| | import re |
| | |
| | text = 'The vote was 65 in favour, 43 against and 21 abstentions' |
| | match = re.search(r'(\d+).*(\d+).*(\d+)', text) |
| | print(match.group(1), match.group(2), match.group(3)) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: 65 2 1
You might have expected to see 65 43 21. The reason for this output is that the .* regular expression is ...
Read now
Unlock full access