fork download
  1. #!/usr/bin/env python3
  2. from string import ascii_lowercase
  3.  
  4. def abcdearian(s):
  5. return issorted_recursive([c for c in s.lower() if c in ascii_lowercase])
  6.  
  7. def issorted(L):
  8. return all(x <= y for x, y in zip(L, L[1:]))
  9.  
  10. def issorted_recursive(L):
  11. return L[0] <= L[1] and issorted_recursive(L[1:]) if len(L) > 1 else True
  12.  
  13. while True:
  14. s = input("String? ")
  15. if not s:
  16. break
  17. print("{} is {}abcdearian".format(s, "" if abcdearian(s) else "not "))
  18.  
Success #stdin #stdout 0.02s 5824KB
stdin
abc
bac
acb



stdout
String? abc is abcdearian
String? bac is not abcdearian
String? acb is not abcdearian
String?