The first digit must be 1 or 7. It can't be 7 as only one digit is correct in each guess. So it's 1.
The other digits in guess #1 (i.e. 3 and 5) must be incorrect.
Therefore, from guess #3, the second digit is 8.
Guess #4 has a correct digit which must be its third ie 2.