Sep-02-2019, 07:50 PM
(Aug-21-2019, 02:17 AM)boring_accountant Wrote: You seem to be confusing English and Python, my friend. The basic idea in Python is that anything that follows if/elif/else are statements that are evaluated to True or False (I'm sure this isn't 100% true all the time but this should suffice for our example here). This means that "if True" does not mean literally "if [blank] is True then...", instead it means "if True is True then...".
Here:#if True is True (True == True, so this is executed) if True: print("1") #else if True is True (True == True, but the previous statement always executes so this does not run) elif True: print ("2") #all other cases (will never happen, same reason) else: print("3")Now, the second example:#If not True (not True == False) is True (False != True, so this does not run) if not True: print("1") #If not False (not False == True) is True (True == True, so this runs) elif not False: print ("2") #all other cases, this never runs, again else: print("3")
Thank you for your reply. Now this makes sense to me, True or False is simply the condition of whether a command will be executed.