#!/usr/bin/env python3
# coding: utf8
'''
Created on October 31st, 2017
@author: Geetanjali
'''
def is_sorted(arr_list):
"""
:param arr_list: the list to be checked if it is sorted
:return flag: is set to True if arr_list is sorted, else is set to False
"""
#We compare pairwise all the adjacent elements in the list to check if the list is sorted.
for i in range(0, len(arr_list)-1):
if(arr_list[i] <= arr_list[i+1]):
flag = True
else:
flag = False
break
return flag
if __name__ == '__main__':
arr_list = []
print("Enter a list: (just enter a non-alphanumeric character to stop)")
flagDigit = False
while(True):
user_input = input()
if(user_input.isalpha()):
arr_list.append(user_input)
print("You started with a list of letters. Make sure you only enter letters and not digits. (just enter a non-alphanumeric character to stop)")
elif(user_input.isdigit()):
arr_list.append(int(user_input))
print("You started with a list of numbers. Make sure you only enter numbers and not letters. (just enter a non-alphanumeric character to stop)")
else:
break
print("Is your list sorted? : "+str(is_sorted(arr_list)))