Creating a List of names

Let’s begin by creating a list using the string variable type since names are strings.

At the start, I can run a foreach loop to pull our names that we created and list them in the beginning.

Now, I want to randomly delete an entry from this list when I press space. To do this, I create a random.range amount based on the name.count (not length, that’s for arrays). Then, I do a name.removeAt — it finds the number in the list and removes that name.

This gives me 9 total names — 5 original names and 4 after the space bar with 1 random name removed.