I wrote this function to check if a given string is in alphabetic order. How can I improve?
def alphacheck(x):
'''This function checks if a given string is in Alphabetical order'''
# Creating a variable to allow me to efficiently index a string of any length
i = len(x) - 1
# Using a recursive formula and checking for the base case when the string is of less than one character
if len(x) <= 1:
return True
# This the recursive portion of the formula
else:
# This code checks if the last two characters are in alphabetical order
# By utilizing the property that the letters of the alphabet increase in "value" accroding to python
if x[i - 1] <= x[i]:
# I remove the last letter of the string to reduce the probelm size
x = x[:i]
# I then repeat this on the smaller string until it reaches the base case or
# Finds out the string is not in alphabetical order and returns False
return alphacheck(x)
else:
return False