ELIF: Sometimes we don't want to evaluate every condition. We can use elif to control how conditions are checked.

if statement conditions are always checked regardless of the conditional before or after it.

elif conditions are only checked if the condition before it was false (elif is a combination of else and if!).

  • Look at the code first. Then click Run and enter a number. Did the program do what you expected it to do?
  • Change each if (except the first one!) to elif instead so that we only see one message from the alien.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)