You do not need to avoid your favorite foods to lose weight.
Weight loss is all about a reduction in calorie intakes. Banning a single food is an over simplistic view of weight loss. Sure if you cannot limit your consumption if ice cream, you need to avoid it. Everyone has a favorite junk food or drink that you have difficulty reducing consumption once you start. But avoiding purchasing will increase its appeal and make you want it more and more. Instead, you should allow yourself to eat the food in moderation instead of banning it. You know your habits, and if you know you will eat a whole box of cookies once you start consuming, then you should only buy one cookie at a time.
Bottom line: Blaming your weight gain or last of weight loss success on a single food is simplistic. Moderation is key, but this too is overly simplistic.