title: Program that stores colors of the rainbow in array and continually prompts user to enter a value from 7 to -1 to end program
body: <p>I'm working on a university python task, in which I am required to write a program that stores the colors of the rainbow in an array, and then continually prompt the user to enter an integer from 7 to -1 to end the code. </p>
  
  <p>Any help would be much appreciated!</p>
  
  <p>I have been able to creat an array, however I have drawn a blank as to how to create the loop. I current have used an if function to test the output.</p>
  
  <pre><code>def r_color(color):
      rainbow = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo']
      if color == -1:
          print("Invalid Input")
      elif 0 &lt; color &lt;= len(rainbow):
          print(rainbow[color - 1])
      else:
          print("Number not in range")
  
  
  user_input = int(input("Please select a number to see the color of the rainbow: "))
  
  r_color(user_input)
  </code></pre>
  
  <p>The expected result should be that the program outputs the color and continiously prompts the user to enter an integer from 7 to -1</p>
  
  <p>It currently outputs one value before terminating the program, which is to be expected given I used a if function.</p>