Puzzle 2 – create an AI bot to guess a number

Step 4 – finding the month you were born in

We can use a linear search to look for anything that's in order.

Like the month of the year you were born in.

  1. Save your program with a new name (something like birthmonth should do)
  2. Remove anything that deals with the variable number from your code. This time we need to deal with months of the year
  3. Change the print lines at the top to something sensible (like "I'm going to guess which month you were born in")

    Now for the tricky bits

  4. We need a variable which list the months of the year in order. To do this, we use a special type of variable called a list. The screenshot shows you how to set it up – but you should type the full names of the months and include all 12 of them!

    Check out the way that this uses square brackets. The items inside the brackets are the list. Each item has a comma between it and the next item

  5. Asking whether the user is born in each month needs a bit of careful thinking
  6. Save your program
  7. Run your program
  8. Run it several times to check it always works right and to correct any errors

Code helper image