I have this text in a PDF: "John is a french person that likes pancakes, he also likes to play soccer"
I want to iterate through the characters in the PDF text three at a time. I tried the below, but I got the error that can only concatenate str (not "int") to str. I understand what this error means, but not sure how to solve this within the code.
pdf_text = pdf_file.getPage(1).extractText()
for c in pdf_text:
print(pdf_text[c:c+3])
I was expecting to get a result, such as:
Joh
ohn
hn
etc...
Any suggestions, with explanation, will be appreciated. Please let me know if you need more information. Thanks.
Edit: I was able to resolve this question utilizing the comment from @slider.
For educational purposes:
for c in range(len(text) - 3):
print(text[c:c+3])