I have been trying these code but there is something wrong. I simply want to know if the first string is alphabetical.
def alp(s1): s2=sorted(s1) if s2 i
You could see this answer and use something which works for any sequence:
all(s1[i] <= s1[i+1] for i in xrange(len(s1) - 1))
Example:
>>> def alp(s1): ... return all(s1[i] <= s1[i+1] for i in xrange(len(s1) - 1)) ... >>> alp("test") False >>> alp("abcd") True