In the exercise five of “Cleaning and Preparing Data in Python” there is the following instruction:
- Use an
ifstatement to check if the value is an empty string. If the value is an empty string, give it the value
So i create the following code (which is correct, but…):
for row in moma: gender = row gender = gender.title() if gender == "": gender = "Gender Unknown/Other" row = gender
(…) in the solution code, there is only an “If not…” Statement.
Why can i use this short code?
for row in moma: # fix the capitalization and missing # values for the gender column gender = row gender = gender.title() if not gender: gender = "Gender Unknown/Other" row = gender