Computer Science, asked by Sayeediqbal6255, 8 months ago

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 letmeanswer12
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