4.14 LAB Count Input Length Without Spaces, Periods, or Commas

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

4.

14 LAB: Count input length without spaces,


periods, or commas
Instructor note:
Note: this section of your textbook contains activities that you will complete for points. To
ensure your work is scored, please access this page from the assignment link provided in
Blackboard. If you did not access this page via Blackboard, please do so now.
Given a line of text as input, output the number of characters excluding spaces, periods,
or commas.
Ex: If the input is:
Listen, Mr. Jones, calm down.
the output is:
21
Note: Account for all characters that aren't spaces, periods, or commas (Ex: "r", "2", "!").

user_text = input()

count = 0

for x in user_text:

if not(x in " .,"):

count += 1

print(count)

You might also like