Python Determine String Length
Given a string, then determine the length of the string.
Example 1: Using the built-in method len()
str = "example"
print(len(str))
The output of the above code is:
6
Example 2: Using a loop to calculate
def findLen(str):
counter = 0
while str[counter:]:
counter += 1
return counter
str = "example"
print(findLen(str))
The output of the above code is:
6Other Extensions
Python3 Examples