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
scontains printable ASCII characters, including spaces.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 8. ⌘Enter runs, ⌘⇧Enter submits.