since available is True, while available in this case evaluates to while True.
But since it's a variable, the same holds for available = False, i.e. 'while False'
This gives you control over how the while loop interprets the condition.
Change the variable, you have changed the condition.
Yes, you're in control, you can do whatever you wish!
In this case you want to use a function:
example:
But since it's a variable, the same holds for available = False, i.e. 'while False'
This gives you control over how the while loop interprets the condition.
Change the variable, you have changed the condition.
Quote: while not available" in this case means True since we have "available = False", rightThat is correct! so the condition 'while not available' means I want to continue this loop while 'not available' is True.
Quote:When adding some third color I first receive Choose size input. Is there any way to avoid this? To get "Please choose the correct color!" immediately if I, for example, type in green colour?
Yes, you're in control, you can do whatever you wish!
In this case you want to use a function:
example:
def choose_item(): color = size = None color = input("Choose color between white and blue: ") if color != 'quit': size = input("Choose size: ") return color, size def check_if_available(color, size): if ((color == 'white' and (size == 'M' or size == 'L')) or (color == 'blue' and (size == 'M' or size == 'S'))): return True else: return False def myControl(): while True: color, size = choose_item() if color == 'quit': break if check_if_available(color, size): print('Available') else: print('Not available') if __name__ == '__main__': myControl()