I find my masters topic extremely hard what should I do?
It's a bit hard to bring this all together to give good advice but let me make a few suggestions. 

With regard to the Python code you are looking at, it is possible that it is just terrible code that no one could understand easily. That may not be the case also, but it happens. On the other hand, if it is a sensible program, then it is probably based on some underlying model that doesn't itself depend on the code. If that is the case, you could find that model and understand it first, then attack the code. The paper you have found probably has some bibliographic references that may help you understand everything. 

Furthermore, you could try to find someone locally who is a Python guru and have them look at the code and give you advice about it - perhaps with the model in hand. 

But your advisor seems to be giving good advice. He or she is the one who will need to approve your result in the end, so it is good to take the advice offered. If doing a bit less is acceptable to them, then it is acceptable, and probably easier. Doing a simpler project should also give you more experience and better enable you to take on harder work later. As a Master's level student it may be a mistake to go beyond the understanding of your professor. Doctoral students normally need to do that, but they have a lot more experience by then. 

Running out of energy (burn out) is a serious academic issue. One way to avoid it is to make a plan, in conjunction with your advisor, that you can execute properly. Once you have a plan it won't feel like you are just thrashing around, as long as you follow the plan.