Jan-09-2024, 09:31 AM
deanhystad Wrote:guard will always be True if you type anything for input("True or false the guard is present on the gate")Correct. didn't pay attention to input statement.
Normally a boolean value is implicitly set:
guard = True
or
guard = False
Then can be used as conditional.
>>> def where_is_guard(): ... if guard: ... print(f"guard is present") ... else: ... print("guard is away") ... >>> guard = True >>> where_is_guard() guard is present >>> guard = False >>> where_is_guard() guard is away >>>