What will be the output of the following Python code? [code]re.compile('hello', re.X)[/code]

What will be the output of the following Python code?
Code:
re.compile('hello', re.X)
A. [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
B. re.compile(‘hello’, re.VERBOSE)
C. Error
D. Junk value
 
Answer: b
Explanation: The compile function compiles a pattern of regular expression into an object of regular expression. Re.X is a flag which is also used as re.VERBOSE. Hence the output of this code is: re.compile(‘hello’, re.VERBOSE).
 

Tìm kiếm

Back
Top