<jupyter_start><jupyter_text>for loops<jupyter_code># for loops
for i in range(1, 10, 2):
    print(i)
# for...else loop
for i in range(1, 5):
    print(i)
else:
    print('printed all items')
# for...else loop with a break
for i in range(1, 5):
    print(i)
    if i > 2:
        break
else:
    print('printed all items')<jupyter_output>1
2
3<jupyter_text>while loops<jupyter_code># while loop
condition = True
i = 0
while condition:
    print(i)
    i += 1
    if i > 3:
        condition = False
# while...else loop
condition = True
i = 0
while condition:
    print(i)
    i += 1
    if i > 3:
        condition = False
else:
    print('done')
# while...else loop with a break
condition = True
i = 0
while condition:
    print(i)
    i += 1
    if i > 3:
        break
else:
    print('done')<jupyter_output>0
1
2
3<jupyter_text>nested loops<jupyter_code>width = 5
chars = "*@"
for char in chars:
    for i in range(1, width):
        print(char * i)
    for j in range(width, 0, -1):
        print(char * j)
width = 5
chars = "*@"
for char in chars:
    for i in range(1, width):
        for spaces in range(width - i, 0, -1):
            print(' ', end='')
        print(char * i)
    for j in range(width, 0, -1):
        for spaces in range(width - j, 0, -1):
            print(' ', end='')
        print(char * j)<jupyter_output>*
   **
  ***
 ****
*****
 ****
  ***
   **
    *
    @
   @@
  @@@
 @@@@
@@@@@
 @@@@
  @@@
   @@
    @
{'fraction_non_alphanumeric': 0.16238723108952116, 'fraction_numerical': 0.025676613462873005, 'mean_word_length': 2.162280701754386, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, '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': '376320', 'license': 'MIT', 'n_tokens_mistral': 582, 'n_tokens_neox': 548, 'n_words': 164, 'path': '_site/lectures/Week 03 - Functions, Loops, Comprehensions and Generators/01.c - Loops.ipynb', 'repo_name': 'BrianKolowitz/data-focused-python', 'size': '1441'}