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
Math,
4 months ago
Chemistry,
4 months ago
English,
4 months ago
Computer Science,
8 months ago
Computer Science,
8 months ago
Physics,
10 months ago
Math,
10 months ago
Science,
10 months ago