Author- Kushank Arora
Tester- Sameer Taneja
Editorialist- Kushank Arora
Nothing except coding is required
The aim is to find the number of spaces in the given sentence.
The problem is to find the number of spaces in the sentence which could be done if we iterate over the string and check if each character is space or not, if it is space, a variable count is incremented to keep the note of the number of spaces.
Firstly use a proper method to input a sentence. To find the number of spaces, a simple algorithm could be used:
count = 0
for i to len(str):
if str[i] = ‘ ‘:
count = count + 1
Thus, count contain the number of spaces, len is the method to find the length of the string.