Note that an empty while loop will tend to freeze resources, so if you don't mind reducing the time resolution, you can enable the sleep statement:
while (GPIO.input(24) != 0): time.sleep(0.1)
This uses fewer CPU cycles, while still testing the condition at a reasonable frequency.
source share