PygLatin - is there a answer so we could compare our work?


#1

There is no way of comparing you code to a right answer, I manage to move on to different stages using different formulas.

Can someone please send the right answer until the new_word = [1:len(new_word)]


#2

Maybe enter your whole code so we can analyze your problems?
Also new_word = [1:len(new_word)] is wrong, you don't refer to the word you try to slice


#3

I am having problem to use the slicing. I don't understand exactly where and how I should use this parameter.
This is my code so far

pyg = 'ay'

original = raw_input('Enter a word:')

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


#4

Well you have done a good job honestly of building this code on your own. Not more help is needed. However, you are missing some key input here. You see to get new_word to equal the slice you must not only equal word+first+pyg but also the [1:len(new_word)] as the instructions tell you: "Use [1:len(new_word)] to do this." To acocmplish this you don't want just the new word printed but the new word print with the slice so you should look to have one more new_word = and change your print to match that new_word =. If you need more examples or such just say so.


#5

Here is an example for slicing:

example = "Example"
example = example[1:3]


#6

Thanks

so I need to create another new_word in addition to the other one created?

new_word = word + first + pyg
new_word = [ 1 : len(new_word) ]

??
This doesnt work. slicing need to be applied to a simple word no? to to something that = to word + first + pyg


#7

Well what already equals word + first + pyg? new_word of course! but however, we need new_word to equal not only that but also the slice. How to accomplish that? Seems like we could make new_word = to not only [1:len(new_word)] but also what? You should also print whatever you = new_word to here as that is what you will want printed out on the console screen.


#8

pyg = 'ay'

original = raw_input('Enter a word:')

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

worked thanks


#9

For just readability sack you should want to turn this into two different new_word equals and then print new_word = new_word[1:len(new_word)] but what you have is fine if it works.


#11

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