Get the length of a string #
You can get the length of a string using the len() function. The len() function takes one argument and returns the length of that argument.
For example:
my_string = "Hello, World!"
length = len(my_string)
print(length) # Output: 13
Exercise #
- Assign the variable
lengthwith the length of the variablegreeting - Use the 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