Summary
In this module, you created an application that prompts users to enter a list of planet names, stores those planet names, and then displays them.
Because you didn't know how many planets users would enter, you used a while
loop. You use while
loops to run a block of code while a condition remains true.
You stored each planet name in a list.
After the planet list was created, you used a for
loop to iterate over it. You use for
loops with lists and other iterables, to run code a known number of times, once for each item in the list of planet names.
In this module, you learned how to:
- Identify when to use either a
while
loop or afor
loop. - Use a
while
loop to run a task multiple times, as long as a certain condition remains true. - Use a
for
loop to iterate over list data.