← 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"))
- A.['2', '5', '0', '3']
- B.['250', '3']
- C.[250, 3]
- 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 →