Vidyalelo
Python · Q45

Regular Expressions in Python

Programming · Python · question 45

Q45

What will be the output of the following Python code? n = re.sub(r' +', 'Hello', 'Cats and dogs')

A.
Hello
Hello
Hello
B.
‘Hello Hello Hello’
Answer
C.
[‘Hello’, ‘Hello’, ‘Hello’]
D.
(‘Hello’, ‘Hello’, ‘Hello’)

Answer: Option B

Solution

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