Pyglatin 10/11 exercise


#1

There appears to be some thing wrong!
My Exercise is as following:

name ="Original"

rat="pyg"

if len(name)>0 and name.isalpha :

word =

name.lower()

print word

first= word [0]

nword =

word+first+rat

print nword

new_word = nword

[1:12]

print new_word

else:

print

"empty"

The ANSWER IS :

original

originalopyg

riginalopyg

None

BUT The COMMENT
is:

Oops, try again. The value for the original variable looks off, make sure
that you entered a word containing only letters.

my "name " contains only alphabets
Please Correct me where i went wrong?


#2

you code looks very un organized so i cant see what you are doing wrong so here is my code. i will take your code and organize it better and see if i can find out whats wrong than reply again with your code and what is wrong with it.

pyg = 'ay'
original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():

word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
print new_word

else:

print 'empty'

#3

Ok here is your cleaned up code. First problem is that you set the variable 'name' equal to a set word instead of letting you choose a word. to fix that change 'name = "Original"' and make it 'name = raw_input("Enter A Word To Change: ")' the exercise says to name the function "original", that doesnt mean right "name = original" the variable should have been 'original = command being executed' and this goes for all the variables. also the 'rat="pyg" function should be 'rat='ay'. the 'if len(name)>0' is just saying 'if len("Original")>0' which "Original" is always going to be 8 letters so it will be greater than 0. Also where it says "name.isalpha:" it should be "name.isalpha():" with the parenthesis. and take out the extra 'print' functions (I will indicate the extras with arrows). Also the "new_word = nword [1:12]" function will only display up to 12 letters, so if someone(you) type a word in the input that is bigger than 12 letters it will cut the word off. To fix this change it from "new_word = nword [1:12]" to "new_word = nword [1:len(nword)]" Which will make it position 1 and keep going until the end of the "nword"

Hope this helped a little. trying to find out why its saying "Oops, try again. The value for the original variable looks off, make sure that you entered a word containing only letters." even tho im only inputting letters.

name ="Original"
rat="pyg"

if len(name)>0 and name.isalpha :

word = name.lower()
print word    <---- (Remove These Extras)

first = word [0]
nword = word+first+rat
print nword    <---- (Remove These Extras)

new_word = nword [1:12]
print new_word

else:
print "empty"
.
.
Final Product

name = raw_input("Enter Word")
rat="ay"

if len(name) > 0 and name.isalpha():

word = name.lower()
first = word[0]
nword = word+first+rat
new_word = nword [1:len(nword)]

print new_word

else:

print "empty"

#4

Found the problem

you have to have the 'rat' variable first and it should be 'pyg' instead of rat
also you have to have it 'original' variable instead of 'name' variable
also change the 'if len(name) > 0 and name.isalpha()' to 'if len(original) >0 and original.isalpha()'
and change the 'word = name.lower()' to 'word = original.lower()'
and finally change the 'nword = word+first+rat' to 'nword = word+first+pyg'

And you should come out with something like this
Working Code

pyg="ay"
original = raw_input("Enter Word")

if len(original) > 0 and original.isalpha():

word = original.lower()
first = word[0]
nword = word+first+pyg
new_word = nword [1:len(nword)]

print new_word

else:

print "empty"

#7

Seems like you're an talented programmer. Haven't seen a such an Easy described formal & clean code in a while


#8

def piglatin():
print "Enter a word!",
word = raw_input().lower()

if (word[0] == "a" or word[0] == "e" or word[0] == "i" or word[0] == "o" or word[0] == "u"):
    print word + "ay"

elif len(word) > 0 and word.isalpha():
    print word[1:] + word[0] + "ay"

else:
    print "You didn't enter a valid word. Only letters, no spaces or symbols!"

piglatin()

here I think this is more simple than what they do in codecademy


#9

How about:

def piglatin():
    woord = raw_input('Enter a word: ')

    if not(woord.isalpha()):
        print "Invalid input, please try again."
        piglatin()

    else:
        print (woord[1:] + woord[0] + "ay").lower()

piglatin()

#11