write a program which takes a list as an input and returns True if the list is sorted and False otherwise

# sorted.py which takes a list as an input and returns True if the list is sorted and False otherwise

one=[1,3,9,8,2]
two=[1,2,3,4]
# size=len(one)
size=len(two)


def sorted_or_not(list_val):
    if list_val == [] or list_val[size-1:] > list_val[size-2:] :
        return True
    else :
        return False     


   
def main():
    if sorted_or_not(two):
        print('It has returned True')
    else:
        print('It has returned False') 

             
 
if __name__=="__main__":
    main()             # call main function







# print("{0:#b}".format(15))
# print(hex(78))
# '0b10110' Print this post

Comments

Popular posts from this blog

write a program that takes as an input a text file. Your program should print all the unique words in the file in alphabetical order.

Perform an in-depth evaluation of the following websites: Website 1: http://jbhifi.com.au Website 2: https://www.amazon.com

Global Bikes INC(GBI) Software Requirements Specifications (SRS)