To my amateur knowledge, an empty string is a string that has length zero. So that must differ from a string that is just spaces right? Even though printing both will appear the same.
I read here (Most elegant way to check if the string is empty in Python?) how to recognize an empty string, but when running this bit of code on what I think is an empty string, it fails:
print("fish:", fish)
if not fish: #if fish is empty string
fish = weight
print("new fish:", fish)
else:
print("fish is not an empty string")
A printout of what fish
is:
fish:
Am I missing something very simple here? Or is fish
indeed a string of spaces and that's why the empty string search fails?
Thanks.