title: Python: while followed by elif
body: <p>I thought <code>else if</code> and <code>elif</code> are logically identical.</p>
  <p>But when I try <code>elif</code> after <code>while</code>, I get a syntax error.</p>
  <p>However, <code>else</code> is OK after <code>while</code>, as shown here (see comments A &amp; B):</p>
  <pre><code>MENU_COMMANDS = {
  'goal': 'the objective of the game is .... ',
  'close': 'exit menu',
  'menu': 'show all menu commands',
  'quit': 'quit game' }
  
  GAME_KEYBOARD = {
  '1': 1,
  '2': 2 }
  
  def turn1():
  key = input(&quot;Player 1, make your move&quot;)  # == 'goal'
  
  while key in MENU_COMMANDS:
      menu(key)
      key = input(&quot;after exiting the menu, make your move&quot;)
  else:  # why not 'elif' ?    COMMENT A
      if key not in GAME_KEYBOARD:
          print(&quot;invalid move&quot;)
          return False
  
  # elif key not in GAME_KEYBOARD:  # why won't this work? :(    COMMENT B
  #     print(&quot;invalid move&quot;)
  #     return False
  </code></pre>
  <p>Is this the only way to execute this logic, or is there a better one?</p>
  <p>Thank you!</p>