Q. What is the output of the following code?

Code:
import re
sentence = 'I am fine'
regex = re.compile('(?P<subject>\w+) (?P<verb>\w+) (?P<adjective>\w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())
  • (A) {‘subject’: ‘I’, ‘verb’: ‘am’, ‘adjective’: ‘fine’}
  • (B) (‘I’, ‘am’, ‘fine’)
  • (C) ‘I am fine’
  • (D) ‘am’
💬 Discuss
✅ Correct Answer: (A) {‘subject’: ‘I’, ‘verb’: ‘am’, ‘adjective’: ‘fine’}

You must be Logged in to update hint/solution

💬 Discussion


📊 Question Analytics

👁️
232
Total Visits
📽️
4 y ago
Published
🎖️
Tanmay
Publisher
📈
84%
Success Rate