<jupyter_start><jupyter_text>LoopsLoops are used in programming to perform repetative tasks. Python supports two different types of loops: a `for` loop and a `while` loop.  The `for` LoopPython `for` loops are used to loop through each item in a sequence such as a list, tuple, or string. A loop variable is defined as part of the for loop to store the current item for each pass through the loop:<jupyter_code>animals = ['dog', 'cat', 'bird', 'fish']

# The loop variable "animal" stores the current item from the list "animals" for each pass through the loop
for animal in animals:
    print(animal)<jupyter_output><empty_output><jupyter_text>The `range` FunctionThe built-in `range` function can be used to easily loop through a range of numbers.<jupyter_code># Loop 5 times
print('Print 5 times:')

# NOTE: the first number returned will be 0
for i in range(5):
    print(i)

# Loop through a specific set of numbers
print('Print numbers 10 to 15:')

for i in range(10, 15):
    print(i)

# Specify increment using the 3rd argument
print('Print every-other number between 15 and 21:')

# Note that the end bound of the loop is not included: 15 >= i < 21
for i in range(15, 21, 2):
    print(i)<jupyter_output><empty_output><jupyter_text>The `while` LoopA `while` loop is used to perform a repetative task until a condition is met.<jupyter_code>x = 0

# Loop while the value of x is less than 5
while x < 5:
    print(x)
    
    # Don't forget to increment x or the loop will go on forever!
    x += 1<jupyter_output><empty_output><jupyter_text>The `break` StatementThe `break` statement can be used within a `for` or `while` loop to exit the loop permaturely. This is often used to exit a loop when some condition is met or an error occurs.<jupyter_code>word = '<PASSWORD>'

# Loop through each character in a string
for letter in word:
    # If the letter is numeric, end the loop
    if letter.isnumeric():
        print(f'{letter} is a number!')
        break
    
    print(f'Current letter: {letter}')<jupyter_output><empty_output><jupyter_text>The `continue` StatementThe `continue` statement can be used within a `for` or `while` loop to skip the rest of the current iteration and start the next iteration.<jupyter_code>word = 'PY<PASSWORD>'

# Loop through each character in a string
for letter in word:
    # If the letter is numeric, skip it the loop
    if letter.isnumeric():
        print(f'{letter} is a number!')
        continue
    
    print(f'Current letter: {letter}')<jupyter_output><empty_output><jupyter_text>The `else` StatementThe `else` statement can be used with loops to execute alternative code when the loop condition fails. This occurs the the end of every loop, with the exception of loops that are exited early using a `break` statment.<jupyter_code># The else is called when a for loop has no more items in the sequence to loop through
animals = ['dog', 'cat', 'bird', 'fish']

# The loop variable "animal" stores the current item from the list "animals" for each pass through the loop
for animal in animals:
    print(animal)
else:
    print('No more animals!')
# If a for loop is given an empty sequence, only sathe else block will be run.
numbers = []

for i in numbers:
    print(i)
else:
    print('Nothing to loop through!')  
x = 0

# The else block will be run when the while condition is False which occurs at the end of the loop
while x < 5:
    print(x)
    x += 1
else:
    print('Done looping.')
for instruction in ['run', 'run', 'run']:
    if instruction == 'stop':
        print('Stopping...')
        break
    print(instruction)

else:
    print('Loop stopped on its own.')<jupyter_output><empty_output><jupyter_text>Exercise1. Write the code that will loop through the given `passwords` list and verify they meet all of the following criteria:    1. Must be at least 8 characters long     1. Must contain at least one uppercase character    1. Must contain at least one lowercase character    1. The password must contain a number    1. Must contain one of the following special characters: !, @, $, &1. Before processing each password, print the following message: "Checking password ..." where  is the count of the password being checked (e.g.: for the first password print "Checking password 1...").1. Print a message that indicates whether or not the password meets the criteria.1. Don't perform the criteria checks if the password is in the `skip` list. Simply print a message that indicates that the password will be skipped and continue the loop with the next password.1. If the word `"suspicious"` is encountered, stop processing passwords, print a warning message, and exit the loop immediately.Hint 1: Use the string methods.Hint 2: Loops can be nested.Hint 3: String are sequences.<jupyter_code># Write code to check these passwords for the criteria listed above
passwords = [
    's<PASSWORD>', '<PASSWORD>', '<PASSWORD>', '<PASSWORD>', '<PASSWORD>', 'sRKU&td',
    '2vuK!N$m', 'n&7aXthU', 'qsE7D8k$j', 'xFza3T$L', '2gJ$De', 'A9jM&wvD',
    '2xTwb$f@', 'M4LWj&nk6', 'B@6Trek4', '', 'Fw!ZU4nYu', 'M2x!Q4Bs', 'ED8t$X65',
    'BNZ93xewFpc', 'pD&Gmk5@', '4hrYwNe35bX', 'vk2!f$gs', 'w8&mJ3', 'MnD&!jhftr',
    '8sna3$Hb', 'u8L$FDmCs', 'X&RscC6N', 'd9Jm&UGE', '$V7xTv', '85ArzUhM49',
    'V@B!3wr8', 'nuJM&g8wK', '$p5AgX', '&3byLd!p', 'aw6MEz$KY', '9j6PJ4@x5',
    '9amgS!Y6', '38bwehm!g', 'ux4m&6F@', 'suspicious', 'eYjSt&Pkxd', 'uw<PASSWORD>', 
    '@wp72FCtq', '<PASSWORD>', '<PASSWORD>', '<PASSWORD>',
]

# Skip these passwords (don't check)
skip = ['<PASSWORD>', '<PASSWORD>', '<PASSWORD>']

# Your code here<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1100410201533797, 'fraction_numerical': 0.018369894774389155, 'mean_word_length': 4.295561850802644, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 44, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '661271', 'license': 'MIT', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1776, 'n_words': 750, 'path': '08 - Loops.ipynb', 'repo_name': 'Aquaveo/python_basics', 'size': '5577'}