I’m trying to make a program in Python that checks if the inputted string is in alphabetical order (abcdearian). The program needs to ignore non-letter characters and treat capital letters as lowercase letters. For example…
abCde is abcdearian and eff!ort is abcdearian.
Right now the program does not ignore non-letter characters, but it does treat capital letters as lowercase letters. However, I want the program to print the original input, and not the converted one. So abCde should show up as abCde (not abcde) when it is printed. Thanks for the help!
def isabcde(s):
for i in range(len(s) - 1):
if s[i] > s[i+1]:
return print(s, "is not abcdearian")
return print(s, "is abcdearian")
while True:
try:
s = input("The string? ").lower()
except EOFError:
break
except TypeError:
break
isabcde(s)
I’d try this:
and if you are ambitious, you may try to replace:
with: