To master python simply takes lots of practice.
I am assuming you're a relative beginner to programming in general. I started out on codecademy.com/learn/learn-python to get the syntax and absolute basics down. Then I progressed to solving "toy problems" on codewars.com and hackerrank.com, using python of course.
To debug my code, I found and used pythontutor.com, which shows how your code is executed step-by-step. After I was fairly comfortable (solved more than 100 problems in python) I started reading "Effective Python" by Brett Slatkin. I highly recommend the book for learning how to properly leverage the strengths of the python language. The book is comprised of many short lessons from beginner stuff such as "how to use enumerate" to more advanced topics such as Object-oriented python and concurrency.