What will be the output of the following Python code? [code]a=re.compile('[0-9]+') a.findall('7 apples and 3 mangoes')[/code]

What will be the output of the following Python code?
Code:
a=re.compile('[0-9]+')
a.findall('7 apples and 3 mangoes')
A. [‘apples’ ‘and’ ‘mangoes’]
B. (7, 4)
C. [‘7’, ‘4’]
D. Error
 
Answer: c
Explanation: The code shown above demonstrates the use of the functions re.compile and re.findall. Since we have specified in the code that only digits from 0-9 be found, hence the output of this code is: [‘7’, ‘4’].
 

Tìm kiếm

Back
Top