Jump to content

Pyg Latin created by the NOOB :) using PYTHON


Recommended Posts

Posted

here is the code of PygLatin game :

 

 

# This is the first line of the program which holds the basic value of our game's 
# core letters "a and y" that gets stick upon the last of original letters!
pyg = 'ay'
# This line contains input
original = raw_input('Enter a word:')
# this one converts the user input to all small alphabetical characters
word = original.lower()
# identifys that user input is not empty only alphabetical
if len(word) > 0 and word.isalpha():
    # stores the first letter of the user input that is to be removerd
    first = word[0]
    # identifys if the first letter if vowel or consonant and print the type
    if first == 'a' and 'e' and 'i' and 'o' and 'u':
        print "This is a vowel."
        # this translates the word by slicing the input from letter 1 to end by 
        # removing the first letter and bringing it to last and adding the 'pyg' 
        # variable value which is the core of the game!
        new_word = word[1:] + word[0] + pyg
        print "Your Translated PygLatin Word is:" + new_word
    else:
        # this also translates the word by slicing the input from letter 1 to end by 
        # removing the first letter and bringing it to last and adding the 'pyg' 
        # variable value which is the core of the game!
        print "This is a Consonant."
        new_word = word[1:] + word[0] + pyg
        print "Your Translated PygLatin Word is:" + new_word 
else:
    print 'empty'
 
 
i think it needs improvements...so please dont shy to reply! .........:)
 
you may try this in labs.codecademy.com
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...