From 3c67bfdff194c903482f301d755c1ba2c7f64013 Mon Sep 17 00:00:00 2001 From: Elizabeth Wickes Date: Fri, 2 Jun 2017 15:01:53 -0500 Subject: [PATCH] changing the text around iterable variable names The original text is quite permissive in the suggestions it makes. These edits propose more conservative suggestions and reminders. --- _episodes/12-for-loops.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/_episodes/12-for-loops.md b/_episodes/12-for-loops.md index e82b25a..d5c6c5e 100644 --- a/_episodes/12-for-loops.md +++ b/_episodes/12-for-loops.md @@ -98,12 +98,15 @@ for number in [2, 3, 5]: * The loop variable, `number`, is what changes for each *iteration* of the loop. * The "current thing". -## Loop variables can be called anything. - -* As with all variables, loop variables are: - * Created on demand. - * Meaningless: their names can be anything at all. - +## Loop variable names follow the normal variable name conventions. + +* Loop variables will: + * Be created on demand during the course of each loop. + * Persist after the loop finishes. + * Use a new variable name to avoid overwriting a data collection you need to keep for later + * Often be used in the course of the loop + * So give them a meaningful name you'll understand as the body code in your loop grows. + * Example: `for single_letter in ['A', 'B', 'C', 'D']:` instead of `for asdf in ['A', 'B', 'C', 'D']:` ~~~ for kitten in [2, 3, 5]: print(kitten)