10/11 help!


#1

HERE IS MY CODE IT WON'T WORK AND I HAVE BEEN TRYING FOR OVER A WEEK TO DO THIS PROBLEM!!!!!!!!!!!!!!!!!!!!!

pyg = 'ay'

original = raw_input('Enter a word:')

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

else:
print 'empty'

#2

First, original does not need to be printed in quotes. Secondly, word does not need to be printed. Thirdly, newword needs to be new_word in all places. Fourthly, your order should be new_word = word + first + pyg then new_word = new_word[1:len(new_word)] and then print new_word with something else.


#3

here is the new code and it still doesn't work:
pyg = 'ay'

original = raw_input('Enter a word:')

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

else:
print 'empty'


#4

Ok again first you need to get rid of print word. That is not needed. You are not printing word but new_word. However, you only need to print new_word one time at the very end right before your else statement. Thirdly

you missed a newword that needs to be new_word. Finally, you have to print new_word but you have to print it with another part of the code. I see you just fixed the newword issue so yeah.


#5

here is the new code:
pyg = 'ay'

original = raw_input('Enter a word:')

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

else:
print 'empty'
and here is the error message:
File "python", line 6
word = original.lower()
^
IndentationError: expected an indented block


#6

Ok so in python you have to make sure your indention are all correct obviously because it is so picky about how you place things. Basic spacing format for this code: (you can tab over the lines)

if statement
     everything under if statement
else statement
     everything under else statement

#7

alright i think i am onto this now here is the new code:
pyg = 'ay'

original = raw_input('Enter a word:')

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

else:
print 'empty'
and the error message:
Traceback (most recent call last):
File "python", line 9, in
NameError: name 'new_word' is not defined


#8

Take out all prints!!!!!! Haha you do not need those at all!


#9

THANKS MAN I FIGURED IT OUT YOU ARE #AMAZING!!!!!!!!!!! :sunglasses:


#10

And you need to have print new_word[1:len(new_word)]


#11

Great! Glad to have helped!


#12

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