string.whitespace in Python
In Python3, string.whitespace
is a pre-initialized string used as string constant. In Python, string.whitespace
will give the characters space, tab, linefeed, return, formfeed, and vertical tab.
Syntax : string.whitespace
Parameters : Doesn’t take any parameter, since it’s not a function.
Returns : Return the characters space, tab, linefeed, return, formfeed, and vertical tab.
Note : Make sure to import string library function inorder to use string.whitespace
Code #1 :
# import string library function import string print ( "Hello" ) # Storing the characters space, tab etc result = string.whitespace # Printing the values print (result) print ( "Geeksforgeeks" ) |
Hello Geeksforgeeks
Code #2 : Given code tests for the whitespace values.
# import string library function import string # An input string. Sentence = "Hey, Geeks !, How are you?" for i in Sentence: # checking whether the whitespace is present if i in string.whitespace: # Printing the whitespace values print ( "printable Value is: " + i) |
printable Value is: printable Value is: printable Value is: printable Value is: printable Value is:
Recommended Posts:
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- SHA in Python
- Python Set | pop()
- Any & All in Python
- max() and min() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : shubham_singh