Python Practice › String Programs › Program 9
String length with a loop
Write a Python program to calculate the length of a string with a loop instead of len().
Input
"sqatools"
Output
8 True
Approach
- Count the characters one by one.
Solution
text = "sqatools"count = 0for _ in text: count += 1print(count, count == len(text))Output
8 True
Learn the concept
New to this topic? Read the lesson, then come back.