What will be the output of the following Python code? [code]w = re.compile('[A-Za-z]+') w.findall('It will rain today')[/code]

Đăng Khánh

New member
What will be the output of the following Python code?
Code:
w = re.compile('[A-Za-z]+')
w.findall('It will rain today')
A. ‘It will rain today’
B. (‘It will rain today’)
C. [‘It will rain today’]
D. [‘It’, ‘will’, ‘rain’, ‘today’]
 
Answer: d
Explanation: The code shown above demonstrates the function re.findall. Since all the words in the string match the criteria, the output of the code is: [‘It’, ‘will’, ‘rain’, ‘today’].
 

Tìm kiếm

Back
Top