# Say you have an encrypted PDF that you have forgotten the password to, but you
# remember it was a single English word. Trying to guess your forgotten password
# is quite a boring task. Instead you can write a program that will decrypt the
# PDF by trying every possible English word until it finds one that works.
#
# Create a list of word strings by reading dictionary.txt. Then loop over each word in
# this list, passing it to the decrypt() method. If this method returns the integer
# 0, the password was wrong and your program should continue to the next password.
# If decrypt() returns 1, then your program should break out of the loop and print
# the hacked password. You should try both the uppercase and lowercase form of
# each word.
#
# Note:
# - Dictionary text file can be downloaded from http://nostarch.com/automatestuff/

# Get dictionary

# Load encrypted PDF

# Try each word in dictionary (upper and lower case)

# Print password, if found

@@ -839,46 +839,322 @@
 f/%0A%0A
-# Get dictionary%0A%0A# Load encrypted PDF
+import PyPDF4%0A%0AFILE = %22../allminutes_encrypted.pdf%22%0A%0A# Get dictionary%0Awith open(%22dictionary.txt%22) as file:%0A    words = file.read().splitlines()%0A%0A# Load encrypted PDF%0ApdfReader = PyPDF4.PdfFileReader(open(FILE, %22rb%22))%0Aif not pdfReader.isEncrypted:%0A    print(%22FileError: PDF is not encrypted%22)%0A    raise RuntimeError
 %0A%0A# 
@@ -1204,17 +1204,39 @@
 r case)%0A
-%0A
+for word in words:%0A    
 # Print 
@@ -1254,8 +1254,244 @@
 f found%0A
+    if pdfReader.decrypt(word) or pdfReader.decrypt(word.lower()):%0A        print(%22The password is either %25s or %25s%22 %25 (word, word.lower()))%0A        break%0A    else:%0A        continue%0Aif word == words%5B-1%5D:%0A    print(%22Failed to break PDF.%22)%0A

Update P4_PDFbreaker working solution