Challenge 3: Colour game

Suggested time: 15 minutes

A program asks the user to guess a random colour. The user keeps guessing until they guess correctly. It does not function correctly yet but when it does, it should behave as shown below:

Using the file below:

Example completed program output

Amend the code to:

  • import a library on original line 6 which is required by the code:
  • add the colour green in to the list on original line 13 between yellow and blue:
    COLOURS = ["red", "orange", "yellow", "blue", "indigo", "violet"]
  • initialise guess variable on original line 20 to an empty string
    guess =
  • choose a random colour from the list on original line 28:
    colour = random.choice()
  • display how many attempts it took to guess the correct answer on original line 35:
    print("Correct! Well done. You guessed in " + attempts + " attempts")

Do not add any additional functionality

If this was a real question it would tell you to save your code as but you might want to save your code so you can show your teacher or come back to it later by pressing Ctrl + S or clicking on the icon that looks like this:

Save / share icon in lets you save your code