Google News
logo
Python Program to Get the length of a list
You can use the built-in function `len()` to get the length of a list in Python. Here's an example program:
Program :
my_list = [1, 2, 3, 4, 5]
length = len(my_list)
print("The length of the list is:", length)
Output :
The length of the list is: 5
In the above program, we first create a list `my_list` containing five elements. Then, we use the `len()` function to get the length of the list and store it in a variable called `length`. Finally, we print out the length of the list using the `print()` function.