So, I am trying to create a program which counts the number of characters in a string which the user inputs, but I want to discard any spaces that the user enters.
You can also do
sum(1 for c in s if c!=' ')
Which avoids any unnecessary temporary string or list.