► Python program to find length of a string using len function


Steps followed:
1. take input from user and store in var variable
2. use len function to return length of the provided string
3. print result 


Program

#python program to find length of a string using len function

#getting input from user and storing in var variable
var=input("Enter a string: ")

#len function returns length of the provided string
length = len(var)

#print result
print("length of the input string - '%s' is %d"%(var,length))
 


Output

Enter a string: sun rises in the east
length of the input string - 'sun rises in the east' is 21





Also Read: