The string module has some of the builtin constant variables. We can use this instead of declaring the constants again in our code. Some of the string constants that will be discussed here are,
Let us look at these constants one by one with a code snippet printing each of these string constants.
The ascii_letters constant is the concatenation of both lowercase and uppercase alphabets as a string. Let us import the string module and print this constant.
The ascii_lowercase constant consists of all the lower case alphabets together as a string. Let us import the string module and print this constant.
The ascii_uppercase constant consists of all the upper case alphabets together as a string. Let us import the string module and print this constant.
The octdigits constant will print all the digits that are allowed in an octal number which is numbers from 0 to 7. Let us import the string module and print this constant.
The punctuation constant has a string of punctuations. Let us import the string module and print this constant.
A string containing all characters that are considered whitespace. On most systems, this includes the characters space, tab, linefeed, return, formfeed, and vertical tab.
If you want to remove punctuations from your code or check if all alphabets exist in your code or something like that we can use these constants.
For more methods and constants visit the official string documentation here.
Happy coding !