HELP! My translator isn't working. 11/11


It always return empty empty. I think my code is fine, though.


Eh. At a glance I’d say that code shouldn’t behave that way but I’d want to run it myself.
Reload page? Otherwise post code (and take care that it’s intact and not re-formatted by the forum or anything as every single character is important in code)



As @ionatan requested, we’d like to have your actual code so we can run it. It is much easier to work with code than with a picture, provided that the posted code is formatted.

In the meantime, it appears in the screen capture that you included a space at the beginning of the word when you entered it. That would make original.isalpha() evaluate to False. if you want a space between the colon and the word in the console, include the space after the colon within the prompt string.


A post was split to a new topic: PygLatin 11/11


Here is the actual 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)]
print original
print ‘empty’

Today, when I entered the word ‘Cookie’ without any spaces. Console gave the 'Cookie. I don’t know why, though.


That is because you have this …

print original

Consider the previous statement, then revise the print statement accordingly to see the actual result.


lol I figured it out.

print new_word

The translator works now. Ty very much