-2

Once i call the main function I get none at the end. How does the code need to be improved to not have it show none in the end of the function call. def count_spaces, then call main function to count number of spaces

  • You're printing the result of `count_spaces()`, but that function does not contain a `return` statement, therefore it returns `None` by default, therefore `None` is printed. – John Gordon Nov 21 '19 at 18:57
  • Please include the relevant code and information as **text** in the question itself. – Thierry Lathuille Nov 21 '19 at 18:58
  • 2
    Sorry, we [can't accept images of code, data or errors](https://meta.stackoverflow.com/a/285557). Post those as *text*, so that we can try to reproduce the problem without having to re-type everything, and your question can be properly indexed or read by screen readers. – Martijn Pieters Nov 21 '19 at 18:59
  • This question is a duplicate of [Function returns None without return statement](//stackoverflow.com/q/7053652); you are using `print()` in two places, and don't return anything from your function. Either remove the `print()` printing what your function returns (which is `None`) or remove the `print()` call in the function and use `return` instead. – Martijn Pieters Nov 21 '19 at 19:01

1 Answers1

0

You're printing the result of the count_spaces function. That function does not return anything (well, actually, a function that doesn't return anything returns None).

So when you do print(count_spaces()), you are printing None.

rein
  • 32,967
  • 23
  • 82
  • 106