Functions · 14 / 27 Exercise Medium

Function count spaces of a text

Objective

Develop a Python program with a function called count_spaces that receives a text and returns the total number of spaces it contains.

Instructions

  • Implement the function count_spaces with a text parameter.
  • In the main function, ask the user for a text.
  • Call count_spaces with the text as an argument.
  • Print the result, which is the quantity of spaces in the text.
Input
Hello, how are you?
Output
3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise