Question: Am trying to write a python program that will prompt a user to type in a string and it will print the number of punctuation
Am trying to write a python program that will prompt a user to type in a string and it will print the number of punctuation marks in that string. below is what i got so far but its not working properly. I need help fixing this code from string import punctuation def count_punctuations(): my_str = input("Enter a string: ") no_punct =0 for char in my_str: if char in punctuation: no_punct = no_punct + 1 print(no_punct) count_punctuations()
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
