Answers for "check if string is blank or have spaces python"

18

check if string is empty python

my_str = ""
if not my_str:
  print("empty")
else:
  print("not empty")
#output: empty
Posted by: Guest on May-09-2020
-1

how to check if a string contains spaces in python

#isspace() is a built-in method used for string handling
string = "My name is"
print(string.isspace())
#It will print True

string = "Hello"
print(string.isspace())
#It will print True
Posted by: Guest on July-14-2021

Code answers related to "check if string is blank or have spaces python"

Python Answers by Framework

Browse Popular Code Answers by Language