'''
import operator
def sorted (a, xs):
'''a is the operator, xs is a list'''
if a == operator.gt:
for i in range(len(xs)):
if xs[i] < xs[i+1]:
return False
else: True
'''
如果我以相反的条件写入它,则会出现错误“IndexError:列表索引超出范围”
if a == operator.gt:
for i in range(len(xs)):
if xs[i] > xs[i+1]:
return True
else: False
海绵宝宝撒
相关分类