I will immediately enter the subject.

First, let me present the current code.

test_dict = {}
test_list = []
for i, item in enumerate (queryset):
    # Process ...
    if condition 1:
        test_list.append (item)
    elif condition 2:
        # Store list in dictionary
        test_dict [item.name] = test_list
        # initialize to reuse test_list
        test_list = [] #  Warning
        test_list.append (item)

Warning for the part of the above code

This list creation could be rewritten as a list literal
Inspection info: This inspection detects situations
                 when list creation could be rewritten with list literal.

As mentioned above,I want to initialize the list located outside the for statementin the for statement and reuse it.
At present, a warning will be issued.
(* Although a warning appears, it is operating normally.)


test_list.clear (), the contents of the list stored in the dictionary are deleted, and I am worried that I could not initialize without some warning.

If i have time and have knowledge oflist initialization, we would appreciate your help.