find the length in python code example
Example 1: how to find length of number in python
len(str(133))
Example 2: 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 3: python lcs length
def lcs(X, Y):
n = len(Y)
m = len(X)
L = [[None]*(n + 1) for i in range(m + 1)]
for i in range(m + 1):
for j in range(n + 1):
if i == 0 or j == 0 :
L[i][j] = 0
elif X[i-1] == Y[j-1]:
L[i][j] = L[i-1][j-1]+1
else:
L[i][j] = max(L[i-1][j], L[i][j-1])
return L[m][n]