Your Code: Enclose your code in 3 backticks
for row in moma: gender = row # convert the gender to title case gender = gender.title() # if there is no gender, set # a descriptive value if not gender: gender = "Gender Unknown/Other" row = gender
What I expected to happen:
‘if not gender’ would look at everything in the data that is ‘not’ in the gender row.
What actually happened:
Replaces empty gender columns with the string.
I was expecting the code logic to come out to something like if gender == ’ '. When i read ‘if not gender’ I expect it would replace everything that is not gender.
Could someone help me understand the logic?