PygLatin: Ending Up


#1

I have tried all possible ways for:-
Set new_word equal to the slice from the 1st index all the way to the end of new_word. Use [1:len(new_word)] to do this.

my code is :
pyg='ay’
word=original.lower()
first=word[0]
new_word=word+first+pyg
new_word=[1:len(new_word)]

which gives me an error msg :-
File “python”, line 5
new_word=[1:len(new_word)]
^
SyntaxError: invalid syntax


#2

you need to include the string/variable containing the string before the square brackets, how else is python to know of what it should take a slice?


#3

tried but no luck.again giving the same error


#4

Can i see what you tried or do i have to guess what you tried?


#5

can u share a code which help me to get pass this activity.
Thanks in advance


#6

Asking and providing full code answers is a violation of the guidelines, if you need more help, you can post an updated version of your code + explain what you do and don’t understand so i can help you, that is the kind of help you can expect from me

i won’t give you the code, you won’t learn anything from it


#7

this is what i tried:-1:
pyg='ay’
word=original.lower()
first=word[0]
new_word=word+first+pyg
new_word=word[1:len(new_word)]


#8

it gives me this error :-
The value for the original variable looks off, make sure that you entered a word containing only letters.


#9

you take a slice of word, why? This mean first and pyg are no longer part of our pyglatin translation. You should take a slice of new_word as a final act on our pyglatin translation to get rid of the first character

taking a slice of word undoes part of what we done earlier


#10

new_word=new_word[1:len(new_word)]
i tried this as wellbut the same error msg :- The value for the original variable looks off, make sure that you entered a word containing only letters.
apologies if i am not able to get what u are saying but i am trying my best to understand this


#11

that is good, what do you enter when raw_input is prompting you for input? Input only a single word, no spaces allowed (spaces aren’t alphanumerical)


#12

Apologies but i didn’t get when u say what do you enter when raw_input is prompting you for input?
there are no space in the code that i have mentioned above::
pyg='ay’
word=original.lower()
first=word[0]
new_word=word+first+pyg
new_word=word[1:len(new_word)]


#13

is this:

pyg='ay’
word=original.lower()
first=word[0]
new_word=word+first+pyg
new_word=word[1:len(new_word)]

all your code? I can’t be, where are the conditions you build earlier for valid the user input and the raw_input() function which prompts the use for a word?

you are prompted for input (by raw_input), what do you enter in this prompt? It should be a single word, no spaces.


#14

This is all what is mentioned step by step in the exercise :-PygLatin


#15

the first lesson of pyglatin contains the steps:

  1. Ask the user to input a word in English.
  2. Make sure the user entered a valid word.
  3. Convert the word from English to Pig Latin.
  4. Display the translation result.

the first two steps are clearly missing in the code you posted, they must be present, otherwise here:

word=original.lower()

original wouldn’t be defined anywhere.

revisit 3. input (link), 4. check yourself and 5. check yourself some more if you don’t remember the code


#16

A post was split to a new topic: Pyglatin: ending up


#17

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