Computer >> Computer tutorials >  >> Programming >> Python

string.punctuation in Python


In this tutorial, we are going to learn about the string.punctuation string.

The string punctuation is pre-defined in the string  module of Python3. It contains all the characters as a string. We can use it anywhere in the program.

Example

# importing the string module
import string
# printing the punctuation
print(string.punctuation)

Output

If you run the above code, then you will get the following result.

!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

Conclusion

We can use it to generate strong passwords. Try it out. If you have any doubts in the tutorial, mention them in the comment section.