4.Check Yourself


#1


Hi. I've got a problem.
I have no idea why the code is not working...
Before I added the part with "IF" the code was perfectly working ....
Now? The only thing I can see is THAT :
< File "python", line 8
print E_word[1:n]+ first + "ay"
^
IndentationError: expected an indented block >

What is more ... This error is about also for : E_word=original.lower()
first=E_word[0]
n= len(E_word) "

I don't know what to do .... Please help me :confused:

print 'Welcome to the Pig Latin Translator!'

original = raw_input("Write an English word:")

 if(len(original)>0):
   E_word=original.lower()
   first=E_word[0]
   n= len(E_word)

print E_word[1:n]+ first + "ay"

 else:
    return "It\'s NOT a word  ! "

#2

The problem is the way you are defining your variables the instructions gave you variable names meaning Eword_ should be called word in order to pass the SCT,

and n should be called new_word ,

also,

you are to store first + word + pyg in the new_word variable and not
'


#3

After correct mistakes there is :
" Traceback (most recent call last):
File "python/cli_runner.py", line 152, in "
And a big window " Something went wrong :frowning:
Click Close to try again or refresh the page"

And refresing the site does nothing


#4

Please post your updated code


#5

print 'Welcome to the Pig Latin Translator!'

original = raw_input("Write an English word:")

word=original.lower()
first=word[0]
new_word= len(word)
print word[1:n]+ first + "ay"

else:
return "It\'s NOT a word -.- ! "


#6

print 'Welcome to the Pig Latin Translator!'

original = raw_input("Write an English word:")
if(len(original)>0):

word=original.lower()
first=word[0]
new_word= [1:len(word)]+ first + "ay"
print new_word
else:
return "It\'s NOT a word -.- ! "


#7

You are missing one important variable and that is a variable named new_word that stores first, word, and 'ay',

new_word = word + first + pyg

Word of advice: To avoid writing 'ay' all the time just store it in a variable and any time you need it just call it by its variable name :slight_smile:


#8

Now I think I've done ALL the corrects.
Right?
( PS. It's still not working ... ) :confused:

orginal = raw_input("Write an English word:")
if(len(orginal)>0):
pyg="ay"
word=orginal.lower()
first=word[0]
n=len(word)
new_word= E_word[1:n]+first+pyg
print new_word
else:
print "It\'s NOT a word!"


#9

original = raw_input("Write an English word:")

if(len(original)>0):

word=original.lower()
    pyg="ay"
first=word[0]
n=len(word)
new_word= word[1:n]+first+pyg
print new_word

else:
print "It\'s NOT a word!"

STILL NOTHIN'

Whaaaat.... :confused:


#10

I told you to discard all references to n this variable should be called new_word and should store the concatenation of word,first, andpyg

should be,

new_word = word + first + pyg


#11

Thank U for your help :wink:


#12

Not necessary to use temporary variables

s = raw_input ('Write an English word: ')
s = s.lower()
if (len(s)>0):
print s[1:len(s)] + s[0] + 'ay'
else:
print "Not a world"


#13

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