10.ending up


#1

it say
Oops, try again. It looks like you printed the correct translation of "h", but make sure to set new_word equal to the slice as well.
i can't find where to solve this

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


#2

You need to add a new line of code ... re-assigning new_word to slice of it (new_word[1:len(new_word)])

Then you will have sliced new_word

After that You can print it.


#3

here:

print new_word[1:len(new_word)]

you print the slice directly, the exercise wants you to first store the slice into new_word (updating the variable) and then print new_word


#4

it still not working


#5

not working
it still the same


#6

can we see an updated version of your code?


#7

thats fine i just get it
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[1:] + first + pyg

print new_word[1:len(new_word)]

else:
print 'empty'

i pass it but why it print the second letter


#8

Your last code was fine..
till this line..
new_word = word + first + pyg

after that you need to re-assign the new_word to slice of it i.e new_word[1:len(new_word)]

what re-assignment means?
Updating value!

if x is a list..

x = [1,2,3,4,5]
and I want to re-assign it to the slice of it (say that slice is x[2:4] ) ,I will do this..
x = x[2:4]

if I have to print this..
I will print x not x[2:4]
as it has slice of itself.

print x #it will print slice of it


#10

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