I have a word/text file containing,
1. 10 Liter sample of an ideal gas is expanded reversibly and isothermally at 300k from initial pressure of 10atm to final pressure of 1atm. The heat absorbed by gas during the process is approximately.
(A)15kJ
(B)23kJ
(C)32kJ
(D)50kJ
[Answer]:(B)
[QuestionType]:single_correct
2. Which of the following statement is correct
(A)Li is hander than the other alkali metals.
(B)In solvay process NH3 is recovered when the solution containing NH4Cl is treated with H2O.
(C)Na2CO3 is pearl ash.
(D)Berylium and Aluminium ions do not have strong tendency to form complexes like
[Answer]:(C)
[QuestionType]:single_correct
I need to get each question in a separate list starting from question number to [QuestionType].
( 1. to [QuestionType])
Output :
[[1. 10 Liter sample of an ideal gas is expanded reversibly and isothermally at 300k from initial pressure of 10atm to final pressure of 1atm. The heat absorbed by gas during the process is approximately.,(A)15kJ,(B)23kJ,(C)32kJ,(D)50kJ,[Answer]:(B),[QuestionType]:single_correct],
[2. Which of the following statement is correct,(A)Li is hander than the other alkali metals.,(B)In solvay process NH3 is recovered when the solution containing NH4Cl is treated with H2O.,(C)Na2CO3 is pearl ash.,(D)Berylium and Aluminium ions do not have strong tendency to form complexes like ,[Answer]:(C),[QuestionType]:single_correct]]
I tried in for loop but cant able to get contents in between
import docx
import re
doc = docx.Document("QnA.docx")
for i in doc.paragraphs:
if re.match(r"^[0-9]+[.]+",i.text):
print(i.text) # matched number condition
if re.match(r"(^\[QuestionType\])",i.text):
print(i.text) # matched QuestionType condition