Yes, it is generally safe for pregnant women to have sex at 31 weeks. However, it is important to consult with your healthcare provider before engaging in any sexual activity during pregnancy. In most cases, as long as there are no complications or medical reasons to avoid sex, it can be enjoyed throughout the entire pregnancy. It is important to communicate with your partner and listen to your body's cues. Some positions may be more comfortable than others due to the growing belly. It is also essential to use protection if there is a risk of sexually transmitted infections (STIs). If you experience any pain, bleeding, or discomfort during or after intercourse, contact your healthcare provider immediately.