how to get a length of a string in python code example
Example 1: how to get the length of a string in python
# Let's use the len() function
print(len("Hello, World!!"))
# this will return 14
Example 2: length of a string python
# 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))
Example 3: python length
# to get the length of a string or array, use the len() method
my_string = "Hello World"
my_list = ["apple", "banana", "orange"]
print(len(my_string)) # outputs 11
print(len(my_list)) # outputs 3
Example 4: length of striung pyhton
len(string)