"ending up" problem


#1

Hey guys. I have been recently introduced to this website, by far i love it. It learns you the basics of progamming. Now ive started the Python progam. But i got stucked. I have to make new_word equal to the slice from the 1st index all the way to the of new_word. I dont understand this part tho

My code looks like this
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[1:len(new_word)]
print original
else:
print 'empty'

The error i am getting is. "Oops, try again. It looks like new_word contains "heyhay" instead of "eyhay"!

If anyone can help me out here, and also explain what for mistake i made i would appreciate it big times :D! Came here to learn :smile:


#2

This is my code. It works.

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


#3

@acermma

I just posted in another topic on this same content.
Post

As to what the issue is,

word = original.lower()
new_word = word + first + pyg

This is your issue right here. You are assigning a variable the whole word then are using it again. As I posted in the other post you just need to do what your problem asked nothing else. Doing extra will confuse you and cause bugs.

Then we just need to solve the problem.

word = raw_input("Enter a word").lower()
if (word and word.isalpha()):
    print(word[1:] + word[0] + 'ay')
else:
    print("Empty")

You can look at the other post that individual also did the same thing you did.


#4

@acermma Just follow the instructions. This instruction said.:
Set new_word equal to .... It means that you should set the [1:len(new_word)] to new_word new_word = new_word[1:len(new_word)]

Like my below code.

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)]    
else:
    print 'empty'