Word Up!/ PLEASE HELP ME!


#1



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


The interper says did you create a variable called word?


I though this was the right code:


Replace this line with your code. 
original = raw_input('Enter a word')
if len(original) > 0 and original.isalpha():
pyg = 'ay'
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word [0]
print first
else:
print 'empty'


#2

Why do you print 'empty' in the last line?


#4

I guess this code works:
original = raw_input('Enter a word:')
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word [0]
print "first"
else:
print 'empty'

However, I haven't clearly understood the working of the code as errors are coming up when I am playing with it.


#5

Answer:

pyg = 'ay'

original = raw_input('Enter a word:')

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


#6

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