Is or isn't

Much like the equals/not equals operator, there is the is and is not operator.

For now, use the is keyword instead of == and is not instead of != when checking equality of booleans and the None datatype as a more semantic way of checking equality. For numbers and strings, it's still best to use == and !=.

Practice time!

Test Cases

test is - Run Test

def test_is():
    assert is_none_var_none is True

test is not - Run Test

def test_is_not():
    assert is_fav_color_green is True

Solution 1

none_var = None
fav_color = "red"

# Replace the ? with the "is" keyword to check if none_var is None
is_none_var_none = none_var is None

# Finish the code to check if fav_color is not equal to "green"
is_fav_color_green = fav_color is not "green"
none_var = None fav_color = "red" # Replace the ? with the "is" keyword to check if none_var is None is_none_var_none = none_var ? None # Finish the code to check if fav_color is not equal to "green" is_fav_color_green = ?