What is the output of the following Python code snippet?
import re
print(re.findall(r'\d+', 'ab12cd345'))
print(re.findall(r'\d+', 'ab12cd345'))
Correct answer
B. ['12', '345']
5 views
B. ['12', '345']
5 views
\d+ matches one or more digits; findall returns all matches.
Asked in: Python Interview Advanced Python
https://docs.python.org/3/library/index.htmlNot sure why the answer is B? Ask here and get an explanation.