Your task is very simple. Just write a function `isAlphabetic(s)`, which takes an input string `s` in lowercase and returns `true`/`false` depending on whether the string is in alphabetical order or not.

For example, `isAlphabetic('kata')` is False as 'a' comes after 'k', but `isAlphabetic('ant')` is True.

Good luck :)

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def alphabetic(s):
	

Solutions:
def alphabetic(s):
	return sorted(s) == list(s)


def alphabetic(s):
	return all((a <= b for (a, b) in zip(s, s[1:])))


def alphabetic(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True


def alphabetic(s):
	return s == ''.join(sorted(s))


def alphabetic(string):
	return string == ''.join(sorted(string))


def alphabetic(s):
	n = len(s)
	c = [s[i] for i in range(len(s))]
	c.sort(reverse=False)
	for i in range(n):
		if c[i] != s[i]:
			return False
	return True


def alphabetic(s):
	arr = [x for x in s]
	return arr == sorted(arr)


alphabetic = lambda str: sorted(str) == list(str)