The answer is yes, but with reservations.
Python is a programming language like Javascript. The difference is that browsers have javascript engines, and can interpret at least HTML and CSS.
Therefore, in the browsers we use today, there is no Python code interpreter or compiler.
The only way to write Python code to run in the browser would be to have Python on the server side, doing server side Rendering, i.e., generating HTML and CSS code.
Another way would be to write Python code to be transposed (compiled + translated) into Javascript. It’s similar to what Typescript does, but a bit more abusive. A project that does this today is the Skuplt. See a example. It is a project that has been receiving a lot of traction and has a lot of potential. It is very useful for generating graphics and things like.
Only if you use Python on back-end. But if you want to use on front-end, it is not possible not to.
– Luiz Felipe