Plan the program
A program is easier to read when each idea has enough room. First describe the goal, then test one small part at a time.
Use names that explain the value, such as
total_score or current_level.
Try the loop
- Start with a short list of values.
- Print one result before adding more logic.
- Check the output after every change.
scores = [3, 5, 8]
total_score = 0
for score in scores:
total_score += score
print(total_score)
Remember
Keep the loop small at first, then add one new rule when the output looks correct.
| Concept | Example |
|---|---|
| Loop | Repeats the same step |
| Condition | Chooses one path |