相关疑难解决方法(0)

Python - 如何检查列表单调性

检查列表单调性的有效和pythonic方法是什么?
即它具有单调增加或减少的值?

例子:

[0, 1, 2, 3, 3, 4]   # This is a monotonically increasing list
[4.3, 4.2, 4.2, -2]  # This is a monotonically decreasing list
[2, 3, 1]            # This is neither
Run Code Online (Sandbox Code Playgroud)

python performance list

60
推荐指数
7
解决办法
3万
查看次数

标签 统计

list ×1

performance ×1

python ×1