Skip to content
Onsite

String Length Using Recursion

EasyP3Coding

Return the number of characters in s using recursion. Do not use s.length or len(s) to get the answer; walk the string one character at a time.

Example 1

Input
s = "hello"
Output
5

Example 2

Input
s = ""
Output
0

Example 3

Input
s = "a"
Output
1

Constraints

  • 0 <= s.length <= 500
  • s contains printable ASCII characters, including spaces.

Hints

Run checks the 3 visible tests, Submit all 8.