Why do I Get `ythonpa` Instead of `ythonpay` When I Enter `Python`?


#1

Why when I do

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)[1:len(new_word)]
  print new_word
else:
  print 'empty'

I get ythonpa for Python instead of ythonpay?


How can I know if my translator works properly?
#2

Hi @blonpina

When I ran your code, it gave me an error on line 8 since you can’t use a variable in the creation of itself. So try changing the end of that line to just this:

[1:]

Doing that will remove the first letter and make the program run properly. After making that change, your code worked fine for me and returned ythonpay when I entered Python.


#3

This topic is solved.