How can you determine the length of a list in Python?
In Python, you can use the built-in `len()` function to get the length of a list. The `len()` function returns the number of elements in the list.
Here is an example:
my_list = [1, 2, 3, 4, 5]length = len(my_list)
print(length) # 输出:5
In the example above, the function `len(my_list)` returns the length of the list `my_list` and assigns it to the variable `length`. Afterwards, the code `print(length)` is used to display the length of the list, which is `5`.
No matter how many elements are in the list, the `len()` function can accurately calculate the length of the list.