What is the output of the following Python code snippet?
import re
print(re.findall(r'[cb]at', 'cat bat rat'))
print(re.findall(r'[cb]at', 'cat bat rat'))
Correct answer
B. ['cat', 'bat']
6 views
B. ['cat', 'bat']
6 views
The pattern [cb]at matches words starting with c or b.
Asked in: Python Interview Standard Library
https://docs.python.org/3/library/index.htmlNot sure why the answer is B? Ask here and get an explanation.