# 列表实战——就地改变列表——其它常见的列表操作

``````>>> L = ['spam', 'eggs', 'ham', 'toast']
>>> del L[0] # Delete one item
>>> L
['eggs', 'ham', 'toast']
>>> del L[1:] # Delete an entire section
>>> L # Same as L[1:] = []
['eggs']``````

``````>>> L = ['Already', 'got', 'one']
>>> L[1:] = []
>>> L
>>> L[0] = []
>>> L
[[]]``````

``````# List
original_list = [1, 2, 3, 4]
copied_list = original_list.copy()
copied_list.append(5)

# Set
original_set = {1, 2, 3, 4}
copied_set = original_set.copy()

# Dictionary
original_dict = {"a": 1, "b": 2, "c": 3}
copied_dict = original_dict.copy()
copied_dict["d"] = 4

# Print results
print("Original list:", original_list)  # Output: Original list: [1, 2, 3, 4]
print("Copied list:", copied_list)      # Output: Copied list: [1, 2, 3, 4, 5]

print("Original set:", original_set)    # Output: Original set: {1, 2, 3, 4}
print("Copied set:", copied_set)        # Output: Copied set: {1, 2, 3, 4, 5}

print("Original dict:", original_dict)  # Output: Original dict: {'a': 1, 'b': 2, 'c': 3}
print("Copied dict:", copied_dict)      # Output: Copied dict: {'a': 1, 'b': 2, 'c': 3, 'd': 4}``````