Skip to content
Related Articles
Open in App
Not now

Related Articles

Python | Functions | Question 7

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

What is the output of the following program :

import re
sentence = 'horses are fast'
regex = re.compile('(?P<animal>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched =, sentence)

(A) {‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’}
(B) (‘horses’, ‘are’, ‘fast’)
(C) ‘horses are fast’
(D) ‘are’

Answer: (A)

Explanation: This function returns a dictionary that contains all the matches.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!