Using Boolean Operators practically?


#1

Was going through the whole lesson on boolean operators and I was wondering when this information may come into play later on in a program I make?


#2

Booleans have some many useful functions. Let's say i make a variable invalid_input and set it to true:

invalid_input = True

and now i am going to make a loop, and prompt the user for input:

while (invalid_input):
    user_input = input("what is your name?")
    # validation of the user input, if valid, set invalid_input to false 
    invalid_input=False

Now, i was a too lazy to write a validation for our user_input, but this way you can use booleans to keep prompting a user until they give valid input. This is just one example, you can use this for many more things. Booleans are very useful