Python Program for Calculating the length of string Without using length() function
Calculating the length of the string without using length() function
Every datatype that stores some value have some length and length of a variable only can be calculated if its datatype can be iterated just like String can be iterated but Integer datatypes are not iterated. One way to find the length of String is by using in-built function len() and the other is by iterating through the string and incrementing the counter by one till loop ends.
- Step 1:- Start.
- Step 2:- Take user input.
- Step 3:- Initialize a count variable.
- Step 4:- Start a for loop by iterating every element of a string.
- Step 5:- Increment count variable by 1.
- Step 6:- Print count.
- Step 7:- End.
Python program to find length of a string without using in-built function
Prime Course Trailer
Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription