← Quiz: Regular Expressions in Python: all 10 questions
Quiz: Regular Expressions in Python · Question 6 of 10
What does this print? (code)
What does this print?
import re
print(re.findall(r"(\w)(\d)", "a1 b2"))
- A.['a1', 'b2']
- B.['a', '1', 'b', '2']
- C.[('a', '1'), ('b', '2')]
- D.[('a1', 'b2')]
Answer & explanation
Correct answer: [('a', '1'), ('b', '2')]
With two groups, findall returns one tuple of groups per match.
Can you get the rest right without peeking?
Take the timed Quiz: Regular Expressions in Python quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →