string punctuation python

import string 
print (string.punctuation)          # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
sentence = "Hey guys !, How are 'you' ?"
for i in sentence:
    if i in string.punctuation:
        print(i)  	 				# ! , ' ' ?

4.33
10
Bippy 8155 points

                                    Syntax : string.punctuation
Parameters : Doesn&rsquo;t take any parameter, since it&rsquo;s not a function.
Returns : Return all sets of punctuation.
CASE: 1  
# import string library function  
import string  
# Storing the sets of punctuation in variable result  
result = string.punctuation  
# Printing the punctuation values  
print(result) 
#OUTPUT : !&quot;#$%&amp;'()*+, -./:;&lt;=&gt;?@[\]^_`{|}~

CASE: 2
# import string library function  
import string  
    
# An input string. 
sentence = &quot;Hey, Geeks !, How are you?&quot;
for i in sentence:   
    # checking whether the char is punctuation. 
    if i in string.punctuation: 
        # Printing the punctuation values  
        print(&quot;Punctuation: &quot; + i) 
   
# Output:

# Punctuation:,
# Punctuation: !
# Punctuation:,
# Punctuation: ?

4.33 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
can python variables have any punctuation python string all punctuation python string.punctuation example python re punctuation python check for punctuation how to print value and punctuation in python find punctuation in string python list of punctuation in python punctuation in python re punctuation module python string.punctuation python 3 how to use punctuation in python string punctuation in strings python python character is punctuation python string only letters punctuation python get words from a string with punctuation Which type of punctuation is used in Python when indicating a string literal? punctuation from string python python is punctuation import string.punctuation python how to check punctuation in python python get words and punctuation in string import punctuations python import punctuation python get off of a string all Punctuation python is punctuation python python string.punctuation string.punctuation python example punctuation symbols in python what is string punctuation in python python strin.punctuation punctuations in python punctuation in python is punctuation in python punctuation string python strings punctuation in python take out punctuation python string.punctuation python python punctuation of letters python punctuation punctuation python python punctuations string python punctuations strings python punctuation strings python punctuation string python string punctuation strings punctuation python strings punctuations python string punctuations python string punctuation python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source