🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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"))
  1. A.['a1', 'b2']
  2. B.['a', '1', 'b', '2']
  3. C.[('a', '1'), ('b', '2')]
  4. 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 →