I'm learning how to do it through codeacademy.com, which is an amazing site. I took there tutorial and used my other knowledge about coding, so with out further ado, here it is: (It's supposed to be a pig Latin translator)
#Zero indexed function that returns the character at the specified length.
def char(string, index0, index1):
if(not len(string)):
return False
else:
return string[int(index0):int(index1)]
#Here we actually do the translation.
def pygLat(string):
if(len(string) and string.isalpha()):
return char(string.lower() + string.lower()[0] + "ay", 1, len(string.lower() + string.lower()[0] + "ay"))
else:
return False
Also, if any of you have pointers/things to fix/see a problem with this, please let me know.