S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
MetaDatum
A bit about bytes…
Category Archives: Monty’s Python
ythonpay
February 10, 2013
Posted by on This was a neat project: (Sorry the indents are not showing)
pyg = ‘ay’
“””This takes user input”””
original = raw_input(‘Enter a word:’)
“””To make it simple, we adjust everything to lowercase.”””
word = original.lower()
“””Holds the first letter of the word”””
first = word[0]
“””The first if/else checks to make sure a word without numbers
or symbols was entered, otherwise it will request only letters”””
if len(original) > 0 and original.isalpha():
print original
“””The second if/else checks to see if the first letter is a vowel
if it is a vowel, ‘ay’ is added to the end of the word and printed
if it is not a vowel the first letter is removed, the appended
to the end of the original word and ‘ay’ is added to the end
then printed”””
if first == ‘a’ or first == ‘e’ or first == ‘i’ or first == ‘o’ or first == ‘u’:
new_word = original + pyg
print “PygLatin: ” + new_word
else:
new_word = original[1:len(original)] + first + pyg
print “PygLatin: ” + new_word
else:
print ‘Letters Onlys!’
Output:
Enter a word:> Python Python PygLatin: ythonpay