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

 Live Demo

# 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.

Updated on: 11-Jul-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements