[英]Check if an item is in the list
I'm a newbie in python. 我是python的新手。 I am making a script that will check if an item on the list is on a particular range, it will do some commands.
我正在制作一个脚本,该脚本将检查列表中的项目是否在特定范围内,它将执行一些命令。 and I have no idea how to make one.
我也不知道该怎么做 Im thinking of using an IF statement, but I think I'm wrong.
我正在考虑使用IF语句,但我认为我错了。
What I have in mind is something like: 我想到的是这样的:
list = [list of values]
if ( an entry on a list is lower than x): #given that x is any number
do this
if any(y < x for y in list):
pass # do something
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.