Question

4.15 LAB: Count input length without spaces, periods, or commas Given a line of text as...

4.15 LAB: Count input length without spaces, periods, or commas Given a line of text as input, output the number of character

4.15 LAB: Count input length without spaces, periods, or commas 

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: "/", "2","!). 

LAB ACTIVITY 4.15.1: LAB: Count input length without spaces, periods, or commas 

main.py 

user_text = input()

''' Type your code here."'

3 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1
user_text = input()
count = 0
for x in user_text:
    if not(x in " .,"):
        count += 1
print(count)

Output

Listen, Mr. Jones, calm down. 21 Process finished with exit code 0

> I input this code and got the right answer but not sure why this is the code

Carmen Cisneros EDU Thu, Dec 2, 2021 2:15 PM

Add a comment
Know the answer?
Add Answer to:
4.15 LAB: Count input length without spaces, periods, or commas Given a line of text as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT