Translator not working


#1

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'

it prints ‘empty’ no matter what I put in when I run it


#2

what do you enter? spaces are not alphanumeric characters, so after the word hit enter right away without typing a space


#3

so I tried to write a word without a space and instead of printing ‘empty’ it’s nothing now


#4

there are no print statement reached when you enter a valid word, so it shows nothing, that is how you coded it


#5

Hey albtoul.

At your 7th line "new_word = new_word[1:len(new_word)] you forgot to make a print statement underneath it.
Make a new line under it and type “print new_word”.

Good luck.


#6

You should
print new_word
after
new_word = new_word[1:len(new_word)]


#7

I really wish they put this in the actual lesson because i was about to continue without it even working so there would be no point. Thank you my guy.


#8

what is the point of

new_word = new_word[1:len(new_word)]

if the program works fine without it?


#9

You would have to have new_word = new_word[1:] to make sure you have removed the first letter of the word.

With the line specified:

Enter a word:test
test
esttay

Without the line:

Enter a word:test
test
testtay

As you can see, leaving out that line would indeed break the translator.


#10

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