Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

length of the string in python

python program to get a String and count the characters in the string

Sample Input 1:

Hello

Sample Output 1:

5

Program or Solution

					    
							
s=input("Enter a String:")
length=0
for i in s:
    length+=1
print(length)

					    
					

Program Explanation

for statement visits all the elements in the string s for i in s count the number of iterations by length+=1