https leetcode comproblemsmonotonicarray check if a list is monotonic ismonotonic1 2 2 3 true ismonotonic6 5 4 4 true ismonotonic1 3 2 false test the function with your examples test the function with your examples https leetcode com problems monotonic array check if a list is monotonic is_monotonic 1 2 2 3 true is_monotonic 6 5 4 4 true is_monotonic 1 3 2 false test the function with your examples test the function with your examples output true output true output false
def is_monotonic(nums: list[int]) -> bool:
    
    return all(nums[i] <= nums[i + 1] for i in range(len(nums) - 1)) or all(
        nums[i] >= nums[i + 1] for i in range(len(nums) - 1)
    )



if __name__ == "__main__":
    
    print(is_monotonic([1, 2, 2, 3]))  
    print(is_monotonic([6, 5, 4, 4]))  
    print(is_monotonic([1, 3, 2]))