What will be the output of the following Python code? [code]sentence = 'horses are fast' regex = re.compile('(?P<animal>\w+) (?P<verb>\w+)

Tam ca

New member
What will be the output of the following Python code?
Code:
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())
A. {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’}
B. (‘horses’, ‘are’, ‘fast’)
C. ‘horses are fast’
D. ‘are’
 

Tìm kiếm

Back
Top