All problems
String Length (No len())
easyPythonStringsLoops
A student is being shown what the built-in string tools actually do underneath, so this exercise takes one of them away. A line of text arrives and its character count has to be reported without calling the built-in len() function. Every character counts, spaces included, and a line with nothing on it holds zero characters.
Task: Print how many characters are in the line, without using len().
Input
A single line holding a string of 0 to 1000 characters. The line may be empty.
Output
One line holding a single integer — the character count. An empty line must still produce a printed 0.
Example:
Input:
hello
Output:
5
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in