Input: a list a of real numbers, of length 0 or greater.
Output: the Boolean valueTrue
if for everyi
in the lista
,a[i] <= a[i+1]
,
otherwiseFalse
.
This is what I have so far but it doesn't work:
def consecutive_elements_equal_or_one_more(a):
for i in range(a)
for i+1 in range(a)
if a[i] <= a[i+1]:
return true
else:
return false
[1, 2, 3]
should return true.
[1, 2, 2]
should return true.
[1, 3, 2]
should return false.