I am trying to write a function that will test whether or not a list is in decending order. This is what I have so far, but it doesn\'t seem to be working for all lists. <
Instead of using indices, you can iterate over the input:
def ordertest(iterable): it = iter(iterable) prev = next(it) for e in it: if e > prev: return False prev = e return True
Note that it's a bad idea to return the strings 'true' and 'false'. Instead, you can use Python's built-in booleans.
'true'
'false'