Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 10 - Lists - Programming Exercises - Page 351: 10.15

Answer

code

Work Step by Step

# 10.15 (Sorted?) Write the following function that returns true if the list is already # sorted in increasing order: # def isSorted(lst): # Write a test program that prompts the user to enter a list and displays whether the # list is sorted or not. def isSorted(lst): for i in range(len(lst)): current = lst[i] for y in range(i + 1, len(lst)): if current > lst[y]: return False return True def main(): lst = input("Enter list: ").split() lst = [int(x) for x in lst] print(isSorted(lst)) main()
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.