{"id":3430,"date":"2021-04-23T13:25:32","date_gmt":"2021-04-23T07:55:32","guid":{"rendered":"https:\/\/python-programs.com\/?p=3430"},"modified":"2021-11-22T18:44:54","modified_gmt":"2021-11-22T13:14:54","slug":"python-check-if-string-is-empty-or-contain-spaces-only","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-check-if-string-is-empty-or-contain-spaces-only\/","title":{"rendered":"Python: Check if String is Empty or Contain Spaces only"},"content":{"rendered":"

Python strings are byte arrays representing characters of Unicode.. However, because Python lacks a character data type, a single character is simply a one-length string. Square brackets can be used to access string elements.<\/p>\n

Given a string, the task is to check whether the string is empty or not.<\/p>\n

Example:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

string=\"\"<\/pre>\n

Output:<\/strong><\/p>\n

Given String is empty<\/pre>\n

Check if String is Empty<\/h2>\n

There are several ways to check whether the string is empty some of them are:<\/p>\n