Course Content
Python Data Structures
Python Data Structures
List Length
When dealing with a sizable list, you might want to know the number of items it contains. You can determine this using the len()
function, which returns the count of elements in the list. Let's dive into how it operates!
Note
A nested list is considered a single item. The
len()
function doesn't count the individual items inside a nested list as separate items of the main list.
x = ['hello', 'Alisa', 5, 23, 'green', 54, 'car', 7] print(len(x))
Task
Determine the length of the list you're working with.
Thanks for your feedback!
List Length
When dealing with a sizable list, you might want to know the number of items it contains. You can determine this using the len()
function, which returns the count of elements in the list. Let's dive into how it operates!
Note
A nested list is considered a single item. The
len()
function doesn't count the individual items inside a nested list as separate items of the main list.
x = ['hello', 'Alisa', 5, 23, 'green', 54, 'car', 7] print(len(x))
Task
Determine the length of the list you're working with.
Thanks for your feedback!
List Length
When dealing with a sizable list, you might want to know the number of items it contains. You can determine this using the len()
function, which returns the count of elements in the list. Let's dive into how it operates!
Note
A nested list is considered a single item. The
len()
function doesn't count the individual items inside a nested list as separate items of the main list.
x = ['hello', 'Alisa', 5, 23, 'green', 54, 'car', 7] print(len(x))
Task
Determine the length of the list you're working with.
Thanks for your feedback!
When dealing with a sizable list, you might want to know the number of items it contains. You can determine this using the len()
function, which returns the count of elements in the list. Let's dive into how it operates!
Note
A nested list is considered a single item. The
len()
function doesn't count the individual items inside a nested list as separate items of the main list.
x = ['hello', 'Alisa', 5, 23, 'green', 54, 'car', 7] print(len(x))
Task
Determine the length of the list you're working with.