Vidyalelo
Python · Q53

Regular Expressions in Python

Programming · Python · question 53

Q53

What will be the output of the following Python code? import re s = 'abc123 xyz666 lmn-11 def77' re.sub(r' ([a-z]+)( +)', r'\2\1:', s)

A.
'123abc: 666xyz: lmn-11 77def:'
Answer
B.
'77def: lmn-11: 666xyz: 123abc'
C.
'abc123:', 'xyz666:', 'lmn-11:', 'def77:'
D.
'abc123: xyz666: lmn-11: def77'

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board