Breastfeeding = birth control

How long do you have to breastfeed for it to be affective at reducing your chances of pregnancy? I know it’s not the best choice of birth control but I’m just wondering how long you’d have to do it for.