Dieting is about changing your eating habits to lose weight. Unfortunately, diets are associated with eating to live instead of eating to enjoy. A diet that only sustains you won't last very long because it's extremely difficult to become accustomed to foods you don't enjoy. It's even harder to give up the foods you love. Successful weight loss is based on a simple rule. If you burn more calories than you eat, the weight will come off. You can check out your daily calorie needs by using a calorie calculator. Once you get an estimation of the number of calories your body burns each day, all you need to do is eat less.
Even if your favorite food isn't the healthiest option (chocolate, pizza, chips, doughnuts) eating it won't necessarily cause your diet to automatically fail. Because dieting is based on the amount of calories, you need to practice moderation when eating foods you love which aren't healthy. If you love pizza, do you really expect your diet to last a long time if you won't let yourself have any?
The problem with diets is that they're built on a foundation of temporary change. You cut calories for a month or two, lose weight and then go back to your old eating habits. This will result in failed diets and only short term weight loss. If you want to permanently stay at your ideal weight, you need to have a long term plan that includes the unhealthy foods you love. Again, moderation is key.
Having a slice of pizza every few days won't kill your diet. Having a few slices every day of the week will. The same goes for chocolate. Having a few pieces today won't throw your diet off track, but having a few bars will. You need to learn to satisfy yourself with smaller portions. You can also build cheat days into your diet which will allow you to have one day each week (or every other week) in which you can eat whatever you want. These days can help you better cope with a strict diet.
The Bottom Line
Food tastes good for a reason: so we'll eat it. If your diet is based on depriving yourself of a food you enjoy, it will fail. Responsibly allowing yourself to eat the foods you love is the only way to achieve long term success.