You should style your code according to the PEP 8 standard which was co-authored by Python’s creator Guido van Rossum. It has very high credibility and Python coders all around the world follow this style guide.
However, the style guide is quite lengthy and boring to read. I would rather recommend that you use an interactive style guide checker to improve your Python coding style over time. It’s also a lot more fun to fix code dynamically.
A great way to learn about how to format Python is an online Python style checker. Just copy&paste your code into the style checker and follow the instructions until your code reaches 100% style score.
These style checkers are mostly based on the official PEP 8 style guide.
Here’s an example of the Pythonchecker.com:

By hovering over the small notification question marks, you’ll get some tooltips that will help you to improve your Python style.

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.