Languages
[Edit]
EN

Python - check if string is empty

0 points
Created by:
Khloe-Kaiser
578

In this article, we would like to show you how to check if string is empty in Python.

Quick solution:

Note:

In Python empty strings are considered as false.

 

Practical example

Edit

In this example, we create a simple if statement to check if the string is empty or not.

Case 1: empty string

Output:

Case 2: not empty string

Output:

Note:

In this example, we don't need print() function because the expression itself returns true or false. It can be replaced with some action.

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Python - string (popular problems)

Python - check if string is empty
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join