From beb933e623036ca835f9fd122c175abf3238a9c2 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 13 Mar 2022 21:28:18 -0400 Subject: [PATCH] [+] Prep9 is_sorted_sublist --- practice/prep9.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/practice/prep9.py b/practice/prep9.py index defa128..548b512 100755 --- a/practice/prep9.py +++ b/practice/prep9.py @@ -66,8 +66,12 @@ def is_sorted_sublist(lst: list, b: int, e: int) -> bool: False >>> is_sorted_sublist([2, 7, 3, 4, 5], 2, 5) # Equivalent to is_sorted([2, 7, 3, 4, 5][2:5]) True + >>> is_sorted_sublist([-1, 0, 0, -1], 0, 3) + True + >>> is_sorted_sublist([-1, 0, 0, -1], 0, 4) + False """ - # TODO: implement this function + return all(lst[i] <= lst[i + 1] for i in range(b, e - 1)) def min_index(lst: list) -> int: