@DGKang Yes although in your case, I think you are trying to calculate from particle A to particle B, so it would be slightly different I think.
I think a good test of your code would be to run an actual molecular dynamics simulation in a software like gromacs or NAMD and then use their tools to get the RDF. Then compare it to the one that you got from python. Their tools have been tested a lot, so it would probably give the right result.