A list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor. HERES THE CODE:

def isSorted(input_list):
if len(input_list)==0 or len(input_list)==1:
return True
else:
for i in range(len(input_list)):
for j in range(i, len(input_list)):
if input_list[j] < input_list[i]:
return False
return True

def main():
lyst = []
print(isSorted(lyst))
lyst = [1]
print(isSorted(lyst))
lyst = list(range(10))
print(isSorted(lyst))
lyst[9] = 3
print(isSorted(lyst))


if __name__ == "__main__":
main()

Respuesta :

Using the knowledge of computational language in python it is possible to write a code that writes a list and defines the arrange.

Writing code in python:

def isSorted(lyst):

if len(lyst) >= 0 and len(lyst) < 2:

return True

else:

for i in range(len(lyst)-1):

if lyst[i] > lyst[i+1]:

return False

return True

def main():

lyst = []

print(isSorted(lyst))

lyst = [1]

print(isSorted(lyst))

lyst = list(range(10))

print(isSorted(lyst))

lyst[9] = 3

print(isSorted(lyst))

main()

See more about python at brainly.com/question/18502436

#SPJ1

Ver imagen lhmarianateixeira