Complete the code to loop through the numbers 1 to 5 and print each number.
for i in range(1, [1]): print(i)
The range function stops before the end number, so to include 5, we use 6.
Complete the code to create a while loop that stops when the variable count reaches 3.
count = 0 while count [1] 3: print(count) count += 1
The loop should continue while count is less than 3.
Fix the error in the for loop to correctly print each item in the list.
items = ['block', 'chain', 'loop'] for [1] in items: print(item)
The loop variable should be item to match the print statement.
Fill both blanks to create a dictionary with words as keys and their lengths as values, but only for words longer than 4 letters.
lengths = {word: [1] for word in words if len(word) [2] 4}We want the length of each word as the value, and only words longer than 4 letters.
Fill all three blanks to create a dictionary with uppercase keys and values only if the value is greater than 10.
result = [1]: [2] for k, v in data.items() if v [3] 10}
Keys are uppercase using k.upper(), values are v, and we filter values greater than 10.