Looping over TH2 bins

How do I loop over all bins of a TH2 from .root file using pyROOT?

Eventually I want to try and distinguish the color of the bin after I loop over it.

P.S. This is what I have so far:

import ROOT

//create a 2D histogram

histo2 = ROOT.TH2F(“histo2”,"",200,-5,5,200,-5,5)

//loop over the bins of TH2

for i in range(1,histo2.GetNbinsX() + 1):
for j in range(1,histo2.GetNbinsY() + 1):

You should use GetBinContent within a Python nested loop.

The “color” of the bin is not part of the TH2D attributes. You will get the bin content.