This reminds me, and I don't know why I didn't think of it sooner. In my experience, keto and intermittent fasting are the best ways to lose weight.
Keto is low carb, which means cutting out starches like bread and potatoes, and sugary foods. Eating fat is desirable because you are training your body to run on the fat you have, but fat eaten with carbs can prevent fast loss. For example, bacon, eggs, and sausages for breakfast is good. Add toast or french toast, and you've gotten off keto and have blocked weight loss.
I've had better luck with intermittent fasting (IF) than keto, though keto certainly helped (I couldn't eat all the fat and animal protein recommended, though I have since discovered that amaranth and buckwheat have all 8 essential amino acids; but I haven't looked to see if they are low carb. Right now, I'm involved in the body ecology diet, which is for health and healing the gut, not weight loss).
Intermittent fasting is great! You choose your eating window and fasting window. For example, my favorite eating window (also called "feeding window" but that makes me think of a horse instead of a human) is 11 a.m. to 7 p.m. or 1 p.m. to 7 p.m., though sometimes I've stopped eating at 6 p.m. Of course, you eat good food during the eating window. Feasting on sugary or high carb foods may not completely defeat your purpose if your fasting window is large enough, but is probably not a good idea, healthwise.
Both keto and IF take some getting used to. If you're interested, I'd recommend looking at the forums on Reddit for both. They usually have links in the right sidebar that will give you basic information, plus the posts are usually by people who have done it or are doing it.
Jason Fung might be someone you want to look up. He's a doctor who discovered that fasting helped his diabetic patients. Healed some of them, I think.
Here are a couple of links about IF.
Jason Fung-What is Intermittent Fasting video
Intermittent Fasting for Beginners