Python Forum
If statement question help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statement question help
#4
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
>>>
Reply


Messages In This Thread
If statement question help - by Gatso100 - Jan-08-2024, 06:00 PM
RE: If statement question help - by Larz60+ - Jan-08-2024, 07:34 PM
RE: If statement question help - by deanhystad - Jan-08-2024, 08:49 PM
RE: If statement question help - by Larz60+ - Jan-09-2024, 09:31 AM
RE: If statement question help - by Pedroski55 - Jan-09-2024, 11:53 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020