🎙 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 1 of 10

What does this print? (code)

What does this print?

import re
print(re.findall(r"\d+", "Rs 250 for 3 pens"))
  1. A.['2', '5', '0', '3']
  2. B.['250', '3']
  3. C.[250, 3]
  4. D.['250']
Answer & explanation

Correct answer: ['250', '3']

\d+ matches one or more digits together, and findall returns strings.

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 →