Python 检查列表项目是否存在
检查列表项目是否存在
要确定特定项目是否在列表中,请使用 in
关键字
示例
检查列表中是否存在 "apple"
thislist = ["apple", "banana", "cherry"]
if "apple" in thislist
print("Yes, 'apple' is in the fruits list")
亲自尝试 »
要确定特定项目是否在列表中,请使用 in
关键字
检查列表中是否存在 "apple"
thislist = ["apple", "banana", "cherry"]
if "apple" in thislist
print("Yes, 'apple' is in the fruits list")
亲自尝试 »
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]