Ending Up


#1


<Dont understand why it isnt working :confused: .>

https://www.codecademy.com/courses/python-beginner-2W5v7/1/4?curriculum_id=4f89dab3d788890003000096.


 pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    word = "original"
    word = original.lower()
    first = "original"[0]
    new_word = word + first + pyg
    new_word = new_word[1:len(pyg)]
    print original
else:
    print 'empty'


#2

pyg = 'ay'

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]
if len(original) > 0 and original.isalpha():

print original

else:
print 'empty'
for some reason this worked but i believe it didnt do what it was suppose to do any idea why


#3

why do I have to restore new_word = new_word...?

does that change what i store in the variable?


#4

I made some changes but you are setting word to a string and first also to a string. When you run you will always get O as the [0] slot. Here is your code modified a little.

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original
word = original.lower()
first = word[0]
new_word = word[1:len(original)] + first + pyg
print new_word
else:
print 'empty'

sorry for the poor formatting


#5

You don't need to have word = original if you are going to change it to word = original.lower() right after.


#6

You're absolutely right thank you. Still learning myself didn't even notice!


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.