A PygLatin example!


#1

Hey! You don't get PygLatin working? Here's an example:

Make sure to understand everything, do not just copy/paste it!

# set the suffix
pyg = 'ay'

# define the requested word
original = raw_input('Enter a random word:')

# convert the word into smallcaps and check if it really is a  
# word, only containing letters
if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    new_word = word[1:len(word)] + word[0] + pyg
    
    # give the answer    
    print "Your word is translated! Your original word was: %s. The new word is: %s" % (original, new_word)

else:
    print "You have to enter a word, only containing letters. Numbers aren't allowed!"

Have a nice day :slightly_smiling:
MatSn0w


#2

@matsn0w,
You could have used

    new_word = word[1:] + word[0] + pyg

Python

== guidance ==
http://legacy.python.org/dev/peps/pep-0008/
http://docs.python.org/2/reference/expressions.html
http://docs.python.org/2/library/functions.html


#3

Yah, good idea! Just a bit shorter :wink: