Why the following code about replace in SymPy have errors?

#1

#2

See an answer here: https://github.com/JuliaPy/SymPy.jl/issues/277 . There needs to be a lambda defined on the python side, not the julia side of things.