I am working my way through a course and there is a piece of code below for a conditional statement. The course says it is testing “if true” I understand what the code is doing but I just don’t understand what is True? In my head it is saying, if true then print true, the output when you run it is: if True, so my head is going round in circles what is True sorry if this is a simple thing but I am the type of person that has to understand what is going on and can’t just skip forward.
I have read around and carried out some research and the nearest I can come to not letting my brain get into and evaluate Pi loop is the following: True is a condition and so True will always = True so the code below if True will always execute, so it’s like saying if mamals breath print mammals breath, well mammals breath so it will always print mammals breath.
After reading further it appears there’s not much use for this and in python 2 you could actually make True not equal True with True=False.
If anyone has a more elegant way of putting this I would like to hear it, or if I am wrong please let me know but above is the only way I have been able to get my head round it.
if True:
print(‘if true’)
elif False:
print(‘elif true’)
else:
print(‘neither true’)