Define 'not working'.
If I upload that code, and then connect A7 to GND, the LED at P1 goes out. As there is probably some noise on A7 that is making it so it is above 0, hence P1 stays lit unless A7 is pulled down (although, if you wanted to keep that behaviour, but make it more reliable, you would change INPUT to INPUT_PULLUP, so that the pin is pulled HIGH/1023 internally).
What did you actually want the code to do?