Answer to Question #197982 in Python for LEROY

Question #197982

Write a function n called is_descending that takes a list of numbers and returs True if the elements are in descending order and False if not. It should just check the users input if its in descending order and returns true if it is and if not false    


1
Expert's answer
2021-05-27T01:57:12-0400
def is_descending(L):
    prev = L[0]
    for i in range(1, len(L)):
        if prev <= L[i]:
            return False
        prev = L[i]
    return True


line = input()
L = [int(w) for w in line.split()]
if is_descending(L):
    print('The input is descending')
else:
    print('The input is not descending')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS