Can anyone help me with this Python issue

I am trying to merge a bunch of pdf files into one file. After doing that I need to take that file and merge it with a second file, but it needs to go (page 1 file A, page 1 file B, page 2 file A, page 2 file B, …) I think that I might be close to making that work, but honestly I’ve watched a bunch of videos and a looked at a bunch of tutorials and I’m just lost. Thanks if anyone can help!

import PyPDF2
from PyPDF2 import PdfFileMerger, PdfFileReader

userpdflocation = os.getcwd() + r"\Print Me\"

os.chdir(userpdflocation)

mergedObject = PdfFileMerger()

for fileNumber in range(1, 300):
mergedObject.append(PdfFileReader(‘OPC_’ + str(fileNumber)+ ‘.pdf’, ‘rb’))

mergedObject.write(“mergedfilesoutput.pdf”)

in1=
PyPDF2.PdfFileReader(“mergedfilesoutput.pdf”)
in2=
PyPDF2.PdfFileReader(“OPC_that_need_printing.pdf”)
out = PyPDF2.PdfFileWriter()
for page1, page 2 in zip(in1 .pages, in2.pages):
out.addPage(page1)
out.addPAge(page2)
with opern(‘outpath.pdf’, ‘wb’ as
file:
out.write(file)

You need to tell us how it “fails”. Looking at this   and this, and a cursory glance over your code, I see nothing obviously wrong.

My suggested version, with formatting:

import os
import PyPDF2
from PyPDF2 import PdfFileMerger, PdfFileReader

userpdflocation = os.path.join(os.getcwd(), "Print Me")
os.chdir(userpdflocation)

mergedObject = PdfFileMerger(False) # don't be strict

for fileNumber in range(1, 300):
mergedObject.append('OPC_' + str(fileNumber)+ '.pdf')

mergedObject.write("mergedfilesoutput.pdf")
mergedObject.close() # cleanup


in1= PyPDF2.PdfFileReader('mergedfilesoutput.pdf')
in2= PyPDF2.PdfFileReader("OPC_that_need_printing.pdf")
out= PyPDF2.PdfFileWriter()

for page1, page2 in zip(in1.pages, in2.pages):
    out.addPage(page1)
    out.addPAge(page2)

out.write("outpath.pdf")