MetaDatum

A bit about bytes…

Category Archives: Monty’s Python

ythonpay

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
HeX-OR Forensics

A bit about bytes...

My Blog

A bit about bytes...

ZoltanDFW

A bit about bytes...