<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_singular(word):
 """Attempts to singularize a word."""

  if word[-1] != "s":
    return word
  elif word.endswith("ies"):
    return word[:-3] + "y"
  elif word.endswith("ses"):
    return word[:-2]
  else:
    return word[:-1]