xxxxxxxxxx
# Python program to demonstrate the use of
# len() method
# Length of below string is 5
string = "geeks"
print(len(string))
# Length of below string is 15
string = "geeks for geeks"
print(len(string))
xxxxxxxxxx
string = "hello"
print(len(string))
#>>> Outputs "5"
if len(string) >= 10:
print("This string is grater then 10")
if len(string) <= 10:
print("This string is smaller then 10")
# Outputs "This string is smaller then 10"
xxxxxxxxxx
# Let's use the len() function
print(len("Hello, World!!"))
# this will return 14
xxxxxxxxxx
#!/usr/bin/python3
str = "this is string example....wow!!!"
print ("Length of the string: ", len(str))
xxxxxxxxxx
Command: len()
What is len: Length Function
Description: The len() function returns the number of items (length) in an object (string, list, tuple, etc.).
Example: length = len("Hello, World!") will return 13.