Number of Segments in a String
A segment is a run of consecutive characters that are not spaces. Return how many segments s has. The string may be empty or have spaces at the start, the end, or several in a row.
Example 1
s "Hello, my name is John"
returns 5
Five segments, because punctuation counts as part of a segment.
Example 2
s " "
returns 0
Constraints
0 <= len(s) <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.