Is True: a suitable way to repeat a block until an accepted case is accepted?

Is it an while Trueaccepted method to cycle through a block of code until an accepted case is reached, as shown below? Is there a more elegant way to do this?

while True:
    value = input()
    if value == condition:
        break
    else:
        pass
# Continue code here.

Thanks for any input.

+3
source share
2 answers

This is the way to do it in Python. You do not need a bit else: pass.

Note that in python 2.x you will most likely need raw_input, not input.

+8
source

, . ( , ), .

, , .

0

Source: https://habr.com/ru/post/1756585/


All Articles