How to get all the punctuation characters from a string in Python

1 Answer

0 votes
import string

s = "#python, php!, java:,c++"

for ch in s:
    if ch in string.punctuation:
        print(ch)


'''
run:
  
#
,
!
,
:
,
+
+

'''

 



answered Nov 8, 2018 by avibootz

Related questions

...