Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialliamthornback2
9,618 PointsShouldn't the test condition of the verify_sort function be "equal to or less than"?
This is what my verify_sorted function looks like:
def verify_sorted(list):
n = len(list)
if n == 0 or n == 1:
return True
return list[0] <= list[1] and verify_sorted(list[1:])
I found that the function would sometimes return False even if the list was actually sorted if there were duplicate numbers.
1 Answer
Victor Cooke
35,162 PointsI believe it should be a <= instead of < as well
Brandon Little
30,417 PointsBrandon Little
30,417 PointsI experienced the same issue, and made the same change.