Written trap python 1

test_list = [
    {'data': 1, 'no': 301},
    {'data': 2, 'no': 401},
    {'data': 4, 'no': 201},
    {'data': 6, 'no': 101},
    {'data': 5, 'no': 303}
]

new_list = list(test_list)
# print(new_list)

for match in test_list:
    if match['no'] > 300:
        match['no'] = 'BF'
    else:
        match['no'] = 'BR'

# print(test_list)

new_list[1]['data'] = 7
new_list.pop()

print(test_list)
print(new_list)

Why not the same result?

The reason:
Written trap python 1
dict () also

Guess you like

Origin blog.51cto.com/9460124/2416859