Skip to content

Instantly share code, notes, and snippets.

@raeq
Created July 19, 2020 09:01
Show Gist options
  • Save raeq/c02f8fc70ed5e88e6c24aa52420020a2 to your computer and use it in GitHub Desktop.
Save raeq/c02f8fc70ed5e88e6c24aa52420020a2 to your computer and use it in GitHub Desktop.
Is Python String Empty or Blank
def is_null_or_blank(input_string: str = "") -> bool:
if input_string:
if input_string.strip():
return False
return True
assert is_null_or_blank(None) == True
assert is_null_or_blank("") == True
assert is_null_or_blank(" ") == True
assert is_null_or_blank(" d ") == False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment