The else and elif Clauses

PHOTO EMBED

Tue Apr 21 2020 12:00:59 GMT+0000 (Coordinated Universal Time)

Saved by @RainbowBlooms #python #python #else #elif #clauses

   >>> x = 20 # x is a variable
  
  >>> if x < 50: # if condition
  ...    print('(first suite)')
  ...    print('x is small')
  ... else: else condition
  ...    print('(second suite)')
  ...    print('x is large')
  ...
 (first suite)
 x is small
                                
                                
content_copyCOPY

In this example, x is less than 50, so the first suite (lines 4 to 5) are executed, and the second suite (lines 7 to 8) are skipped.