Complete the code to get an iterator from the list.
my_list = [1, 2, 3] my_iter = [1](my_list)
The iter() function returns an iterator object from an iterable like a list.
Complete the code to get the next item from the iterator.
my_list = [10, 20, 30] my_iter = iter(my_list) item = [1](my_iter)
The next() function returns the next item from an iterator.
Fix the error in the code to correctly iterate over the list using an iterator.
my_list = [5, 6, 7] my_iter = iter(my_list) while True: try: item = [1](my_iter) print(item) except StopIteration: break
The next() function is used inside the loop to get each item until StopIteration is raised.
Fill both blanks to create a dictionary of squares for numbers greater than 2.
numbers = [1, 2, 3, 4, 5] squares = {num: num[1]2 for num in numbers if num [2] 2}
The ** operator is used for exponentiation (square), and > filters numbers greater than 2.
Fill all three blanks to create a dictionary with uppercase keys and values greater than 10.
data = {'a': 5, 'b': 15, 'c': 20}
result = { [1]: [2] for k, v in data.items() if v [3] 10}Keys are converted to uppercase with k.upper(), values are v, and filter uses > to select values greater than 10.