Ahh, yes..It was a typo. Or to be more accurate, a copy-and-pasteo (which was playing up!) sorry...!
As to your second point..I have made a modification thanks to your hint. I've also done a different version of the function. Which do you think is a better example of code practice?
I have tested both and can find no errors.
Many thanks for your input !
def is_sorted(t):
""" checks to see if a list is in ascending order"""
for look in range(0,len(t)-1):
if t[look] > t[look+1] or t[-2] > t[-1]:
return False
return True
print is_sorted([1,3,5,8,7])
print is_sorted(['c','e','g'])
def another_is_sorted(t):
""" checks to see if a list is in ascending order"""
for look in range(0,len(t)-1):
first_item, next_item = t[look], t[look+1]
if first_item > next_item:
return False
return True
print another_is_sorted([2,4,6,])
print another_is_sorted(['a','b','d','c'])