Home  >  Article  >  Backend Development  >  How to determine whether a list contains an element in python

How to determine whether a list contains an element in python

高洛峰
高洛峰Original
2016-10-17 11:34:342017browse

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.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn