|
1 | | -# 5. Data Structures |
| 1 | +# 5. Cấu trúc dữ liệu |
2 | 2 |
|
3 | | -This chapter describes some things you’ve learned about already in more detail, and adds some new things as well. |
| 3 | +Phần này sẽ mô tả những gì bạn đã học qua và đi sâu hơn, bổ sung một số phần mới nữa nhé! |
4 | 4 |
|
5 | | -### 5.1. More on Lists |
| 5 | +### 5.1. Nhiều hơn về Lists |
6 | 6 |
|
7 | | -The list data type has some more methods. Here are all of the methods of list objects:`list.append`\(_x_\) |
| 7 | +Kiểu dữ liệu list có khá nhiều phương thức để xử lý. Sau đây là tất cả các cách ấy: |
8 | 8 |
|
9 | | -Add an item to the end of the list. Equivalent to `a[len(a):] = [x]`.`list.extend`\(_iterable_\) |
| 9 | +`list.append`\(_x_\) Nối thêm một phần tử vào cuối danh sách. Tương tự như là `a[len(a):] = [x]`.`list.extend`\(_iterable_\) |
10 | 10 |
|
11 | | -Extend the list by appending all the items from the iterable. Equivalent to `a[len(a):] = iterable`.`list.insert`\(_i_, _x_\) |
| 11 | +mở rộng danh sách bằng cách thêm tất cả các phần tử từ iterable. Tương tự `a[len(a):] = iterable`.`list.insert`\(_i_, _x_\) |
12 | 12 |
|
13 | | -Insert an item at a given position. The first argument is the index of the element before which to insert, so `a.insert(0, x)` inserts at the front of the list, and `a.insert(len(a), x)` is equivalent to `a.append(x)`.`list.remove`\(_x_\) |
| 13 | +Chèn một phần tử vào vị trí nào đó trong danh sách. Thông số đầu tiên là vị trí của phần tử phía trước, hay `a.insert(0, x)` sẽ chèn ngay đầu danh sách, và `a.insert(len(a), x)` tương tự với `a.append(x)`.`list.remove`\(_x_\) |
14 | 14 |
|
15 | | -Remove the first item from the list whose value is _x_. It is an error if there is no such item.`list.pop`\(\[_i_\]\) |
| 15 | +Loại bỏ phần tử có giá trị là _x_ trong danh sách. Nó sẽ lỗi nếu không có phần tử thích hợp.`list.pop`\(\[_i_\]\) |
16 | 16 |
|
17 | | -Remove the item at the given position in the list, and return it. If no index is specified, `a.pop()` removes and returns the last item in the list. \(The square brackets around the _i_ in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.\)`list.clear`\(\) |
| 17 | +Loại bỏ phần tử có vị trí _i_ và trả về nó. Nếu không có vị trí nào đặc biệt được chỉ định, `a.pop()` loại bỏ và trả về phần tử ở cuối danh sách. \(Dấu ngoặc vuông quanh _i_ trong phương thức biểu thị rằng thông số là tùy chọn chứ không phải bạn nên gõ nhé. Bạn sẽ nhìn thấy ký hiệu này thường xuyên khi tham chiếu với thư viện của Python.\)`list.clear`\(\) |
18 | 18 |
|
19 | | -Remove all items from the list. Equivalent to `del a[:]`.`list.index`\(_x_\[, _start_\[, _end_\]\]\) |
| 19 | +Loại bỏ tất cả các phần tử trong danh sách. Tương tự với `del a[:]`.`list.index`\(_x_\[, _start_\[, _end_\]\]\) |
20 | 20 |
|
21 | 21 | Return zero-based index in the list of the first item whose value is _x_. Raises a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) if there is no such item. |
22 | 22 |
|
|
0 commit comments