Exercise 7 of 10 · Lists
Household Chore Rotation
What you will make
A program that builds a rotating list of household chores by adding names and prints whose turn is next.
The one new idea: Using a List<string> to add items dynamically and read its Count
Arrays have a fixed size decided up front; a List<T> can grow as you add to it, which matches how many real lists — chores, guests, orders — actually get built up over time.
Go straight to the code ↓An array's size is fixed the moment you create it. A List<T> is different — it can grow as you go, which is a much better fit for something built up piece by piece, like a rotation of names. new List<string>() starts empty, .Add(item) appends an item and changes the list in place, and .Count tells you how many items are currently in it. Indexing works just like arrays: list[0] is the first item.
Worked example
Here's a supply list for a school art project, built up with Add:
List<string> supplies = new List<string>();
supplies.Add("construction paper");
supplies.Add("glue sticks");
supplies.Add("safety scissors");
Console.WriteLine($"Items needed: {supplies.Count}");
for (int i = 0; i < supplies.Count; i++)
{
Console.WriteLine($"- {supplies[i]}");
}Items needed: 3
- construction paper
- glue sticks
- safety scissorsEach Add call changes supplies directly — there's no need to reassign the variable or capture a return value.
Your turn
The starter code builds a chore rotation by adding four names one at a time, but the last call uses .Append("Sam") instead of .Add("Sam"). Append is a different, LINQ-provided method: it returns a brand-new sequence with the extra item tacked on, but it leaves the original list completely untouched — and since nothing here captures that returned sequence, "Sam" never actually joins the rotation. Fix the call so it really adds Sam to the list.
If something goes wrong
If the printed count is one lower than you expect, or the last name you added is missing from the printed list, check every method call that's supposed to change a list and confirm it's actually a mutating method like Add, Remove, or Insert — not a LINQ method like Append, Where, or Select, all of which return a new sequence instead of changing the original.
Write your code
Runs in your browser. Press Run (or Ctrl/Cmd+Enter) and the output is checked for you.
Press Esc then Tab to move keyboard focus out of the code editor.
Output will appear here after you run your code.The runtime is starting in the background. You can type now — it will be ready before you are.
The answer appears here once you have run your code at least once.
Things that often go wrong here
- Confusing Add (mutates the list) with Append (a LINQ method that returns a new sequence).
- Append leaves the original list completely unchanged, so anything added this way silently never shows up.
- Forgetting List<T> indices start at 0, same as arrays.
- list[0] is the first item, not list[1], which matters once you start looping with an index.
- Trusting .Count without checking whether every intended item was really added.
- A method call that looks like it should add an item, like Append, might compile fine while doing nothing to the actual list.
Want a blank editor instead? Open the C# playground.