Yes. The main home exclusion applies.
If you owned and lived in the house for two of the five years before the sale, then up to $250,000 of profit is tax-free. If you are married and file a joint return, the tax-free amount doubles to $500,000. The law lets you "exclude" this much otherwise taxable profit from your taxable income
If you sold the home in 2017, you would have needed to live in to for 3 years of the last 5. Counting back from the month you sold it 7/17 for 5 years, that would be 7/12. You did not live in it from 10/15-7/17 which is 21 months. When you subtract 21 months you did not live out of the 60 months, you meet the test because you lived there 39 months out of the last 60 months.