Get the length of a list #
You can get the length of a list using the len() function the same way you can get the length of a string.
For example:
numbers = [1, 2, 3, 4, 5]
length = len(numbers)
print(length) # Output: 5
Exercise #
Get the length of the variable names with the function len() and assign the length to another variable names_length
Tests #
- Variable
names_lengthshould be5 - Must use function
len()
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules