Students build a playlist kept in two parallel lists, Titles and Artists, where a song's title and artist sit at the same place in each. Add puts a value on the end of both lists; clicking a title removes ClickedIndex from both. The Check shows what happens when only one list changes: every later song gets the wrong artist. This is the problem the next lesson's table solves.
Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Try 5 min · Build 1–2 15 min · Check 10 min · Make it yours 15 min
This lesson uses only what App Builder apps taught (lists, List objects, ClickedIndex), at Level 3. Its point is the problem, not the solution: keep the lesson short and let the third list in Make it yours feel clumsy.
Songs and artists are made up. Students can use their own made-up songs; keep real song lyrics out.
Lists count from 1 in App Builder (ClickedIndex, item(list, 1)). Python counts from 0; that's for later.
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
Only their place in each list links them. Keep this question open: the next lesson answers it with a table.
Write Titles and Artists as two columns. Cross out Arc in Titles only, close the gap, and draw an arrow from each title to the artist beside it now.
Every arrow below the removed song points to the wrong artist. Each list is fine on its own: the mistake is in how they line up.
The bug is invisible until the second list is looked at: each list is fine on its own. Have students read the two lists side by side, row by row, after every removal.
| What you will see | A question to ask | The fix |
|---|---|---|
| Nothing is added. | Which event runs when Add song is clicked, and does it name both lists? | Check the event's condition is AddButton is clicked, with two Add to the end of list actions. |
| Clicking a title does nothing. | Which List's items does the event listen to? | Use An item in TitleList is clicked, and Remove item ClickedIndex (not 1) from each list. |
| The lists are different lengths. | Is there an event that changes only one list? | Every add and every remove must change both lists. Press Start again to get the starting lists back. |
One possible solution for each task. Other correct programs are fine.
{"version":1,"name":"Two lists","device":"web","features":{"level":3},"variables":[{"name":"Titles","value":["Blue Sky","Arc","Cove"]},{"name":"Artists","value":["Kai","Mo","Lu"]},{"name":"Lengths","value":[3,5,4]}],"screens":[{"id":"home","name":"Home","objects":[{"name":"Title","kind":"text","instanceVars":[],"instances":[{"id":"h1","x":24,"y":16,"w":500,"h":40,"text":"My playlist","visible":true,"vars":{}}]},{"name":"TitleLabel","kind":"text","instanceVars":[],"instances":[{"id":"l1","x":24,"y":70,"w":90,"h":36,"text":"Title","visible":true,"vars":{}}]},{"name":"TitleInput","kind":"input","instanceVars":[],"instances":[{"id":"i1","x":110,"y":66,"w":200,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"ArtistLabel","kind":"text","instanceVars":[],"instances":[{"id":"l2","x":330,"y":70,"w":90,"h":36,"text":"Artist","visible":true,"vars":{}}]},{"name":"ArtistInput","kind":"input","instanceVars":[],"instances":[{"id":"i2","x":410,"y":66,"w":200,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"LengthLabel","kind":"text","instanceVars":[],"instances":[{"id":"l3","x":24,"y":116,"w":90,"h":36,"text":"Minutes","visible":true,"vars":{}}]},{"name":"LengthInput","kind":"input","instanceVars":[],"instances":[{"id":"i3","x":110,"y":112,"w":200,"h":42,"text":"","visible":true,"vars":{}}]},{"name":"AddButton","kind":"button","instanceVars":[],"instances":[{"id":"b1","x":630,"y":64,"w":140,"h":46,"text":"Add song","visible":true,"vars":{}}]},{"name":"Hint","kind":"text","instanceVars":[],"instances":[{"id":"t1","x":24,"y":160,"w":600,"h":30,"text":"Click a title to remove that song.","visible":true,"vars":{}}]},{"name":"TitleList","kind":"list","instanceVars":[],"instances":[{"id":"L1","x":24,"y":200,"w":240,"h":260,"text":"","visible":true,"vars":{},"source":"Titles"}]},{"name":"ArtistList","kind":"list","instanceVars":[],"instances":[{"id":"L2","x":280,"y":200,"w":240,"h":260,"text":"","visible":true,"vars":{},"source":"Artists"}]},{"name":"LengthList","kind":"list","instanceVars":[],"instances":[{"id":"L3","x":536,"y":200,"w":240,"h":260,"text":"","visible":true,"vars":{},"source":"Lengths"}]}],"events":[{"id":"e1","else":false,"conds":[{"type":"onClicked","target":"AddButton"}],"actions":[{"type":"listAdd","list":"Titles","value":"TitleInput.text"},{"type":"listAdd","list":"Artists","value":"ArtistInput.text"},{"type":"listAdd","list":"Lengths","value":"int(LengthInput.text)"}],"children":[]},{"id":"e2","else":false,"conds":[{"type":"onItemClicked","target":"TitleList"}],"actions":[{"type":"listRemoveAt","list":"Titles","index":"ClickedIndex"},{"type":"listRemoveAt","list":"Artists","index":"ClickedIndex"},{"type":"listRemoveAt","list":"Lengths","index":"ClickedIndex"}],"children":[]}]}]}
Open task: any program that does what the step asks.
Stretch: Add a Sort A to Z button. With only the list actions, how close can you get, and what goes wrong? (A table, next lesson, sorts whole rows.)
Support: Build 1 together as a class; pairs do Build 2.
Two lists: Names (Ana, Ben, Cy) and Scores (7, 4, 9). Ben is removed from Names only. What score does the app now show for Cy?
4: Cy moved up to place 2 in Names, and place 2 in Scores is still Ben's 4.
Next: One table instead, where each song is one row and can't be split up.