else statements are sort of like a function, executing if something is true/ false.
number = 5 #here, we have are variable, number. 5 is stored in it
if number == 5: #here's our first statement. If number (5) is equal to 5...
print number #number is printed
else: #if number is not equal to 5, we execute this statement...
print "None" #..and print none
If we didn't nestle the
print number under our statements, the statements won't work, and Python will throw an error.
There's not much else to say. I mean, if you decided to put
print number above your statements, it will still print
5, but if you changed the value of
number = 6), Python will execute the second statement which is the
else statement. Like I said above, these are great for checking if something is true or false, and as you get more advanced, you can do much more with these statements rather than checking if a number/string is true/ false.