Is there a short contains function for lists?

Use:

if my_item in some_list:
    ...

Also, inverse operation:

if my_item not in some_list:
    ...

It works fine for lists, tuples, sets and dicts (check keys).

Note that this is an O(n) operation in lists and tuples, but an O(1) operation in sets and dicts.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)