10. Mix 'n' Match


#1



https://www.codecademy.com/courses/python-beginner-BxUFN/2/6?curriculum_id=4f89dab3d788890003000096#

So the console says "Oops, try again. Make sure you have a value for all 5 variables!" but I do have a valid value for each line.

Error message:
File "python", line 13
bool_four = 1 != 5 not 2 == 2

SyntaxError: invalid syntax


# Use boolean expressions as appropriate on the lines below!

# Make me false!
bool_one = (2 <= 2) and "Alpha" == "Bravo"  # We did this one for you!

# Make me true!
bool_two = 2 != 3 or 4 < 5

# Make me false!
bool_three = 3 == 3 and 4 == 5

# Make me true!
bool_four = 1 != 5 not 2 == 2

# Make me true!
bool_five = 5 != 2 and 6 != 4


#2

here:

bool_four = 1 != 5 not 2 == 2

you have to use or or and to combine the 2 conditions, you can also use not, but not standalone between two conditions


#3

not is a modifier more than a logical operator. It does not have a left side operand.

not True            =>  False

True not True       =>  Error

True and not False  =>  True

False or not False  =>  True

Note how the operator precedes the modifier.


#4

I was also wrong in this lesson but I managed to pass it by changing the Boolean operator to and.

It's like the @mtf member said: "The Boolean operator does not return True for false statements and False true statements."
For example: not False will result in True, while not 41> 40 will return False.

If you still do not understand the issue, comment. I can be much clearer in the answer.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.