The value of moma is not what we expected

Screen Link:

My Code:

for row in moma : 
    Gender = row[5]
    if not Gender: 
        Gender = "Gender Unknown/Other"
    row[5] = Gender
    Nationality = row[2]
    if not Nationality : 
        Nationality = 'Nationality unknown'
    row[2] = Nationality

What I expected to happen:
that values in moma dataset will be changed

What actually happened:

value didn’t change…: or something else

The value of moma is not what we expected.
One of your variables doesn't seem to have the correct value. Please re-check the instructions and your code.```

Check the question and my response here - Trying to understand why do I have to assign a variable inside a for loop - #3 by the_doctor to see what you could potentially be doing wrong. Compare my response to your code and try to understand it first.

Secondly, pay closer attention to the case you use for strings. It’s Nationality Unknown (U and not u)

1 Like

Thank you. I’ve noticed that my mistake was not assigning the capitalized value to the same variable, but please could you explain more why do I have to do this assignement.

The link I shared does explain the why. Is there anything specific that’s unclear to you?

thank you, after revisiting the post, things are clear!

1 Like