@heenakhan.khatri For situations where you might accidentally pass in a non-string value (say from user input or API responses), I’ve found this pattern helpful:
python
Copy
Edit
if isinstance(my_string, str) and not my_string:
It ensures you’re checking only actual strings and avoids surprises with None, 0, or other types.
A little more defensive, but it’s saved me from runtime errors in data-heavy scripts or quick CLI tools.