Home > Backend Development > Python Tutorial > How to use python to determine whether a list contains an element

How to use python to determine whether a list contains an element

高洛峰
Release: 2017-03-16 16:28:05
Original
3490 people have browsed it

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'
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template