Why is "not(True) in [False, True]" False?

Asked 1 years ago, Updated 1 years ago, 97 views

False in [False, True] = True Why? not(True) in [False, True] = False

Is it? not(True) is False?

python python-2.7 python3

2022-09-22 08:16

1 Answers

This is because of the priority of the operator. This is because in has a higher priority than not.

(not True) in [False, True] I think you thought it was handled in the same way as

in reality not (True in [False, True]) Because it's processed in the same way.

Also, not is not a function, so it is not recommended to use it with not().


2022-09-22 08:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.