CONDITIONALS: You can do many different types of tests with conditionals. Let's practice using a new test.

The in operator checks whether a value is present in a list or string. If it's there, then the condition is True.

  • Click Run and answer the question. Did you get it right? Right now the condition only allows for one color!
  • Edit the condition in the if statement to use this code: if user_input in rainbow_list:
  • Click Run and enter any color of the rainbow! Now there are multiple correct answers.

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)