The best way to prevent pregnancy is to practice abstinence. If you have sex, use contraception or birth control methods to prevent pregnancy.
Always use a condom, to not only prevent pregnancies, but to also protect yourself from diseases.