Contact: aviboots(AT)netvision.net.il
39,931 questions
51,868 answers
573 users
def isInAlphabeticalOrder(s): for i in range(len(s) - 1): if s[i] > s[i + 1]: return False return True s1 = "python c++" print(isInAlphabeticalOrder(s1)) s2 = "abcxyz" print(isInAlphabeticalOrder(s2)) ''' run: False True '''
def isInAlphabeticalOrder(s): return s == ''.join(sorted(s)) s1 = "python c++" print(isInAlphabeticalOrder(s1)) s2 = "abcxyz" print(isInAlphabeticalOrder(s2)) ''' run: False True '''