I can't imaging losing weight consistently without exercise. Diet is most important. However even for the most obsessed of us counting calories is difficult to get right all of the time. Muscle mass consumes calories and exercise creates a deficit. Both provide margin that help account for calorie counting mistakes. I find that exercise forms a virtuous cycle in dieting. If I go on a 500 calorie bike ride that's 500 more calories I can eat that day.
That's not quite what I am saying. You need to learn about calories and build a proper intuition about them before really getting into exercising. Otherwise you end up easily out eating what you burn.
I have known way too many people who regularly exercise but still cannot lose weight. The problem they have is that thry burn 500 calories exercising, and then go unknowingly eat 900 calories because they exercised.
You need to learn how to handle hunger. To control your own urges. Once you do, dieting becomes easy, the only part that sucks is the low energy and irritability.
Intermittent fasting is a great teacher in this regard.