PygLatin - Ending Up


#1

https://www.codecademy.com/en/courses/python-beginner-2W5v7/1/4?curriculum_id=4f89dab3d788890003000096#

First I don't think i understand the instruction anymore. Very Frustrating. Arrrrrrggggggh!

"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."

okay

so i wrote these lines of codes:

pyg = 'ay'

word = raw_input('ORIGINAL')
first = raw_input('o')
new_word = word[0]
   
if len(word) > 0 and word.lower():
    print word
    print first
else:
    print 'empty'
first = 'first'[0]
print [1:len(new_word)]

Quiet frankly, i don't know. The instruction and hint is not clear.

Replace this line with your code.


#2

I dont want to give up here.

someone help please.


#3

you did go wrong somewhere, this is right:

pyg = 'ay'

word = raw_input('ORIGINAL')
if len(word) > 0 and word.lower():
   # we continue coding here

then we need to set original to lower, and store it in word:

if len(word) > 0 and word.lower():
   word = original.lower()

then create first, which should be the first letter:

word = original.lower()
first = word[0]

then below first we need to create new_word under first, which you did in exercise 9, i recommend to revisit this exercise. then set a slice of new_word and store it in new_word, take a look at first to get an idea of how to achieve this

If you need more help, post an updated version of your code. But first revisit some of the exercises, your code became a bit of a mess


#4

Thanks.

this is what i have done.

pyg = 'ay'

word = raw_input('ORIGINAL')
if len(word) > 0 and word.lower():
word = original.lower()
first = 'word'[0]

new_word = '[1:len(new_word)]'

...........................
Error Message:

Oops, try again. Your code did not run to end - see the console window for the error message.

ORIGINAL original
Traceback (most recent call last):
File "python", line 5, in
NameError: name 'original' is not defined

......................................................


#5

how did i made such a mistake? you should store the result of raw_input into original:

original = raw_input("Enter a word")
if len(original) > 0 and original.isalpha():
   word = original.lower()

then you should check if the length is greater then zero, and it are all letters. Then you can store a lowercase version in word.

then here:

first = 'word'[0]

word is a variable, so don't use '.

you didn't revisit exercise 9, please do:

first = word[0]
# code of exercise 9 on this line

new_word = '[1:len(new_word)]'

uhm... this line:

new_word = '[1:len(new_word)]'

you should take a slice of new_word, you didn't specify what the slice you should be of:

new_word = new_word[1:len(new_word)]

again, this is not a string so no need to use quotation marks.


#6

@apoetisaman
Stetim's answer is exactly right


#7

Thanks @stetim94 and @tagjumper54263

I finally solved the exercise:

Just so that I can get the full reflective value from your assistance and corrections please see the code i wrote below;

I just dont want to solve the exercise so your comments will be appreciated.

.................

pyg = 'ay'

original = raw_input("WORD")
if len(original) > 0 and original.isalpha():
word = original.lower()

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


#8

Really happy...:smile:


#9

where did this go:

else:
   print 'empty'

? add it at the end:

pyg = 'ay'

original = raw_input("WORD")
if len(original) > 0 and original.isalpha():
   word = original.lower()

   first = word[0]
   new_word = original + first + pyg
   new_word = new_word[1:len(new_word)]
else:
   print 'empty'

then you got it spot on :slight_smile:


#10

You really should thank stetim than me because he is the one who really explained the things. I just supported and that's it. :sunny:


#11

Fixed that.

Thanks :grinning:


#12