3.6.1.6 – Operations on lists 2 | in, not in

3.6.1.6 – Operations on lists 2 | in, not in

Python offers two very powerful operators, able to look through the list in order to check whether a specific value is stored inside the list or not.

These operators are:

The first of them (in) checks if a given element (its left argument) is currently stored somewhere inside the list (the right argument) – the operator returns True in this case.

The second (not in) checks if a given element (its left argument) is absent in a list – the operator returns True in this case.

Look at the code in the editor. The snippet shows both operators in action. Can you guess its output? Run the program to check if you were right:


Fonte: https://edube.org/study/pe1

Sandbox: https://edube.org/sandbox

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.

%d blogger hanno fatto clic su Mi Piace per questo: