Whatever you do to lose weight - you now have to do that (or something equivalent) forever.
People often "go on a diet" to lose weight. You don't "go on" a diet - everyone is on a diet all the time. It's just that there are bad diets and good diets. Bad diets make you fat, good diets make you less fat. If you want to lose weight forever, you have to change your diet. Permanently. There is no way around this, unless you want gastric-bypass surgery or lap-band surgery - which is expensive and has risks and side-effects.
The key to losing weight is to watch what you eat. A lot of overweight people protest that they do not overeat, claiming that they just eat what everyone around them eats. Studies show that they are either lying or are grossly misinformed about what "everyone around them eats". You can search this up on PubMed, but studies show that overweight people chronically under-report or underestimate how much they eat - by a LOT. If you are overweight, sorry, but chances are you got that way by either overeating, eating the wrong food, or just being immobile for long periods of time. That's just medical fact.
Of course there are a few people who suffer from very unusual and RARE conditions that make the body overweight - microscopic tumors that can secrete appetite-stimulators and so forth - but again, these problems ARE RARE. VERY RARE. The amount of overweight people who claim to suffer from these conditions far, far, far, far, far exceeds the prevalence rate.
Cut Junk Food, get a lot of sugar out of your diet, cut down on fats, watch what the labels say on the packages and exercise more. That's all you need to do to lose weight.
It is also one of THE HARDEST THINGS TO DO, EVER. I'm not going to lie - it is INCREDIBLY difficult to lose weight and keep it off through dietary changes alone. Once you are obese, your brain thinks that's the weight you should be at - any attempt to lose weight will trigger your brain to think you are literally starving. And it's not just the amount of food - it's what you eat as well - if you've been taking a lot of sugar for decades, the moment you stop your brain is going to act like something seriously wrong has happened and will THROW A FIT. It will use every trick in the book to make you eat sugar again. When you are losing weight, your brain will literally make you think you're dying. You're not, of course, but your brain wants you to think you are. Unfortunately, we evolved on the Savannah plains, in an environment of scarcity. Food supplies were never secure. Our brains evolved to make us retain weight as much as possible, because we didn't evolve in an environment were food was common. To our primitive areas of our brain, losing weight is the equivalent of suicide.
All this means that once you're fat, you are very, very, very unlikely to go back. Do you know what the success rate is for losing weight through life-style medication and keeping it off is? It's about 3~4% or even less than that. The vast, vast, vast majority of people who try to lose weight through dieting alone don't make it. Those that do are unusually strong willed people, probably far more strong-willed than I or you.
Many doctors are despairing at the failure to address the obesity epidemic through diet and exercise. Unfortunately, this generation of obese people are done for. The vast majority of them will never, ever lose their weight, unless they get surgery, and it's just not feasible to provide millions upon millions of people with this surgery. Our efforts are focused on preventing the obesity problem from growing and saving the next generation.
But yes - more exercise, less fat and sugary foods. The sugar is the problem, because sugar turns into fat very easily. Carbohydrates also get turned into fat quite easily. Watch what you eat, how much you eat and if you have a VERY strong will (stronger than mine, even though I'm not overweight and never have been, I admit that if you can lose weight permanently you probably have a stronger will than I do), then you can lose weight forever.
Or get surgery. Which I don't recommend unless you are very obese.