I am trying to access my variable but it say name is not defined, Here I read pdf file
def read_pdf(file):
with open(file, "rb") as f:
pdf = pdftotext.PDF(f)
st.write('button clicked',file[:-4]+'.txt')
with open(file[4:-4]+'.txt', 'a') as f:
for page in pdf:
f.write("%s\n" % page)
return " ".join(pdf)
if st.button('read_pdf'):
para = read_pdf('qna/'+filename)
st.write('length of text: %s' % len(para))
Here I can get length of para.
sentence = st.text_input('Input your Question here:')
if sentence:
st.write('length of text: %s' % len(para))
st.write('length of sentence: %s' % len(sentence))
But here it say
NameError: name 'para' is not defined