Python | Functions | Question 7
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 = re.search(regex, sentence) print(matched.groupdict()) |
chevron_right
filter_none
(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
Recommended Posts:
- Python | Functions | Question 2
- Python | Functions | Question 6
- Python | Functions | Question 5
- Python | Functions | Question 4
- Python | Functions | Question 3
- Python | Functions | Question 1
- Python-Quizzes | Functions | Question 9
- Python-Quizzes | Functions | Question 8
- C | Functions | Question 10
- C | Functions | Question 3
- C | Functions | Question 11
- C | Functions | Question 11
- C | Functions | Question 6
- C | Functions | Question 9
- C | Functions | Question 4


