In this post, we will see how to Calculate the Length of a String Without Using an inbuilt Function.
Step 1: Declare a String and store it in a variable.
Step 2: Declare a variable stringLength and initialize it to 0.
Step 3: Use a for loop to iterate over the string and increment the stringLength variable for each character in the string.
Step 4: After completing the for loop print the value of stringLength variable.
Step 5: End.
Input: "Welcome to Python Programming"; Output: Length of the string is: 29
string="Welcome to Python Programming"; stringLength=0 for i in string: stringLength=stringLength+1 print("Length of the string is: ") print(stringLength)
Length of the string is:29