Write the output of the following code.
#!/usr/bin/python
str = " "
print str.isspace( )
str = "This is string example….wow!!!"
print str.isspace( )
Answers
Answered by
1
The output is:
True
False
Explanation:
The isspace() method for python string tests if the string consists of white space. It returns true if the string includes only white space characters. Otherwise, it would return false.
In the given code snippet:
- str = " "
- print str.isspace( )
The above statement when executed since the string contains only whitespace character it returns a value as True.
- str = "This is string example….wow!!!"
- print str.isspace( )
The above statement when executed since the string contains other than whitespace character it returns a value as False.
The output is:
- True
- False
Similar questions
Hindi,
6 months ago
Math,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Physics,
1 year ago
Math,
1 year ago
Science,
1 year ago