Course: Learn Swift > Conditionals & Logic > Lesson Logical Operators

In the Lesson called Logical Operators, there is a problem calling for the programmer to put print statements in the correct place depending on the state of the conditional in an if statement.

If I understand correctly (pardon the unintentional use of the word “if”), the syntax of an if statement calls for the first section to execute when the conditional is true. The other section, in the “else” portion executes when the conditional is false.

By following the convention of holding the context of the Boolean variable to indicate its state, “feelingWell,” means true indicates the person is feeling well. They are not feeling weIl when the variable is false. Because the not operator, !, is in use, the variable state is negated. Therefore feelingWell actually needs to be false for the first condition to be true.

I could change the state of feelingWell to be false to make it work the way Codecademy provides its answer but I am sticking with my own code as it never says you are allowed to change the variable. It might be a fine point but I think, valid.

Here is the link:

Here is my version, which does the work but differs from the provided solution:
var feelingWell = true

if !feelingWell {
// add a print() statement here
print(“Embrace the day!”)
} else {
// add another print() statement here
print(“Have some vitamins and and take care of yourself :face_with_thermometer:”)

I will change my code to fit the solution to continue on with the section.

I think I see the logic of providing the solution the way you did. I think I was getting hung up in the literalness of the syntax of the if statement and not the way it read. The value of true being required for the first part of the if statement to execute.