The only sure way to prevent pregnancy is not to have sex.
If you and your partner decide to have vaginal sex, there are ways to lower your chances of getting pregnant:
The best way to prevent pregnancy and STIs is to use condoms and birth control together.