The # sign used for code comments causes folding problems

I collapsed everything before leaving the note, but when I opened the note again I noticed that part of it was not collapsed in, I suspect that the # in the code block is causing the problem, but I don’t know how to fix it?