python punctuation
import string
print (string.punctuation) # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
sentence = "Hey guys !, How are 'you' ?"
for i in sentence:
if i in string.punctuation:
print(i) # ! , ' ' ?
python punctuation
import string
print (string.punctuation) # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
sentence = "Hey guys !, How are 'you' ?"
for i in sentence:
if i in string.punctuation:
print(i) # ! , ' ' ?
string punctuation python
Syntax : string.punctuation
Parameters : Doesn’t take any parameter, since it’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 : !"#$%&'()*+, -./:;<=>?@[\]^_`{|}~
CASE: 2
# import string library function
import string
# An input string.
sentence = "Hey, Geeks !, How are you?"
for i in sentence:
# checking whether the char is punctuation.
if i in string.punctuation:
# Printing the punctuation values
print("Punctuation: " + i)
# Output:
# Punctuation:,
# Punctuation: !
# Punctuation:,
# Punctuation: ?
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us