<jupyter_start><jupyter_text>While loops

Unlike `for` loops, `while` loops will keep executing a set of statements as long as the condition is True.

The basic structure for a while loop is: 

```
while [condition is true]: 
    [keep doing stuff]
```<jupyter_code># this statement never stops executing - becareful when running it! It could crash or slow down your computer. 
# make sure to stop the execution
while True:
    print("Just keep swimming...")<jupyter_output><empty_output><jupyter_text>How to safely use a while loop

Make sure that the condition used with the while loop will result in the while loop ending. For example...<jupyter_code># keep printing i until it reaches 5
i = 1
while i < 5:
  print(i)
  i = i + 1 # important: we need to increment i, in order for this to work<jupyter_output><empty_output><jupyter_text>Nested for loops<jupyter_code># a list of students with a list of scores (a list within a list)
students = [
    {
        "name": "Tom",
        "scores": [50, 80, 75, 45.2]
    },
    {
        "name": "Jerry",
        "scores": [40, 20, 60, 33]
    },
    {
        "name": "Susan",
        "scores": [80, 10, 95]
    }
]
# print out all scores using two for loops
for student in students: 
    for score in student["scores"]:
        print(score)<jupyter_output>50
80
75
45.2
40
20
60
33
80
10
95
{'fraction_non_alphanumeric': 0.09977989728539985, 'fraction_numerical': 0.036683785766691124, 'mean_word_length': 3.011764705882353, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '563377', 'license': 'MIT', 'n_tokens_mistral': 481, 'n_tokens_neox': 439, 'n_words': 182, 'path': 'day-1/08-ins_more-loops/solved/more-loops.ipynb', 'repo_name': 'jonathanneo/intro-to-python', 'size': '1363'}