Sentences as Lists

Processing a Sentence

The pattern of using an index variable to process a bunch of values is pretty common in programming, and is not specific to lists alone! The block on the left below is the one that we used to say all of the names in our player list. The block on the right can be used to say all of the letters in a sentence like “Go Longhorns!”

Players Sentence

There are striking similarities between the two scripts, and so we should be able to perform the same tasks on sentences as those we did on lists. Write blocks that make the character say the following:

  • Every other letter in a sentence.
  • Every third letter.
  • The letters in reverse order.
  • Say a range of letters, using either a repeat until or a repeat block.

Note: Often, when writing a script, if we have already written a similar script for another purpose or data structure, we can either modify the script for the new functionality, or we can create a more general script that can be used for both purposes.