My code works, but it's not the "official" way, so I'm still stuck at this excersize!


#1


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

It works perfectly after you type it in twice. The first time simply repeats the word that it did last, the second time does exactly what its supposed to.

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

#2

It works perfectly after you type it in twice

It throws an error, can you elaborate on It works perfectly ? (I just have tested it)

Hint**
Read instructions again!

further hint**

You have tried to slice word even before defining it.
When a variable is not defined (by defined I mean if It carries any data in it)
It will throw an error if you try to do any calculation using it.

do reply if you get the hints or not!


#3

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