Screen Link:
In the exercise five of “Cleaning and Preparing Data in Python” there is the following instruction:
- Use an
if
statement to check if the value is an empty string. If the value is an empty string, give it the value"Gender Unknown/Other"
.
So i create the following code (which is correct, but…):
for row in moma:
gender = row[5]
gender = gender.title()
if gender == "":
gender = "Gender Unknown/Other"
row[5] = 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[5]
gender = gender.title()
if not gender:
gender = "Gender Unknown/Other"
row[5] = gender