64.4k views
3 votes
Given a line of text as input, output the number of characters excluding spaces, periods, or commas. If the input is:

Listen, Mr. Jones, calm down. The output is 21

1 Answer

1 vote

In python 3.8:

print(len([x for x in input("Enter your text: ") if x not in "., "]))

I hope this helps!

User Martijn Thomas
by
5.6k points