Some exceptions to this, for example if I am trying to unfuck something the client was responsible for, or they hired me specifically to solve this problem and I was clear up front that I would charge them for the time it took to figure out wtf was going on.
But let's say I decided to write a bit of Python code to solve a problem. And then I run into some obscure bug in one of the libraries I selected. If I can't figure that out quickly then I pause the project and switch to debugging the library and maybe even submitting a pull request, then I go back to the client project. Same if I need to learn some new library, or a new language, etc. If it's not the client's fault that I selected a library that had edge cases I wasn't aware of, why should they pay me to figure that out?