Last active
July 26, 2016 09:39
-
-
Save rugk/012a68c0fe559e942d22 to your computer and use it in GitHub Desktop.
Codeacademy - Python course: Pig Latin (PygLatin) https://www.codecademy.com/learn/python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# constants | |
pyg = 'ay' | |
# input | |
original = raw_input('Enter a word:') | |
# check for errors | |
if len(original) > 0 and original.isalpha(): | |
print original | |
else: | |
raise ValueError('invalid input') | |
# process input | |
word = original.lower() | |
first = word[0] | |
slipped_word = word[1:] | |
# new word: previous word without first char + first char + pyg ending | |
new_word = slipped_word + first + pyg | |
#output | |
print new_word |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the great help.
your tutorial is very helpful.