I went to the doctor for the first time in decades. Blood pressure high, told to cut sodium, so I did. Was simpler than it sounds (because of my specific circumstances). Felt better. Lost weight.
After a fasting lab panel had a follow-up appointment six weeks later. "You have diabetes." Managing food intake for that is more complicated than a single line on a nutrition label and just avoiding "added sugar" isn't enough to avoid my kidneys doing the work that insulin couldn't. Felt better. Lost weight.
All of this to say that my diet changes are because I have a reasonable financial budget for groceries, sufficient time to shop, and a social environment in which there is not a cost for eating what I need and there is not a social cost for not eating what I should avoid.
Time, money, and relationships are the necessary conditions of habit development. If I was trying to feed a family of four from the bodega on minimum wage, pills would be about the only viable option.
It's also worth noting that my habits are easier to maintain because I feel better. If it were just a matter of weight loss, I doubt they would stick anymore this time than previously when I lost weight but didn't feel better chemically and my hunger still there.
YMMV. Good luck.