The earlier programs in this studio show how variables can be used to remember something and coordinate the actions of two or more sprites. In this program, we explore a special kind of variable called a list. A list is a variable that can remember multiple things at the same time. For example, it can remember the numbers 10, 20, and 30. To retrieve one of these things, the program must use the INDEX of the thing in the list. The first thing in a list always has an index of 1, the 2nd has an index of 2, etc. So, in our example, if the list is called numbers, we'd have number[1] = 10 number[2] = 20 number[3] = 30 The number inside [] is the INDEX.
This program simulates a waiter asking two people what they'd like to eat and then repeats the items back to them. The cat is the waiter. Try 1. Run the program once and see what it does 2. Look at the blocks and see what it does 3. Run it again 4. Did the cat forget what you told it the first time? 5. why does the cat remember what you said the first time you ran it? 6. How do you fix this problem. HINT: you have to make the cat forget what it was told before. Experiment with the "delete" block. Feeling adventurous? Try this now ... 1. notice how the program repeats what was ordered. It does so by saying each item one at a time. Change the program so it deletes an item from the list as soon as it says that item. When the loop finishes, there should be no more items in the list. 2) modify the program to have the cat repeat what you said in reverse order. That is, if you told the cat "bat", "ball", "map", the cat should first say "map", then "ball", then "bat". 3. modify the program so that the cat says in one single sentence all the words you entered. The sentence might be stored in a variable called "what you want". 4. modify the program so that it deletes an item from the list as soon as the item is added to this variable. The goal for the list variable to have no items when the loop exits. Be careful about indexes. For example, in the example above, suppose you delete the first list item "10". What would be the index of the 2nd item then? It won&;t be 2. 5. change your program to use the "replace" block. For example, the cat could ask you in the second loop if you wish to update your answer, and if so, replace the word you entered with a new one you entered.