Home > Article > Backend Development > How to use python to determine whether a list contains an element
In python, you can use the in and not in keywords to determine whether a list contains an element
pythontab = ['p','y','t','h','o','n','t','a','b'] if 't' in pythontab: print 't in pythontab' if 'w' not in pythontab: print 'w is not in pythontab'
in and not in are very commonly used Keywords.
The above is the detailed content of How to use python to determine whether a list contains an element. For more information, please follow other related articles on the PHP Chinese website!