Says its correct but i need to set new word equal to slice?


#1

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

else:
print 'empty'


#2

new_word should contain the correct translation, and then you can just print new_word:

print new_word

without any manipulation

so the result of slicing in new_word (update the variable)


#3

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 original 
print new_word

else:
print 'empty'

Still dosent work
so confused


#4

new_word = word + first + pyg 
# below take a slice and update new_word variable

# below print new_word

#5

I'm am utterly hopeless still cant do it

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

print original 
print new_word

#6

so close, here:

new_word [1:len(new_word)]

you take the slice, but you need store it in new_word, updating the variable so your new_word variable contains the final translation


#7

what do I change then


#8

this line:

new_word [1:len(new_word)]

you need to store the slice in new_word variable:

new_word = # store slice here

Why are you struggilng with updating a variable so much?


#9

I think something else has gone wrong as it still dosent work

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

print original 
print new word

else:
print 'empty'


#10

look at this code:

x = "hello world"
x[0:6] # not storing result of slicing action
print x # output: hello world
x = x[0:6] # storing result of slicing action
# which you need to do so new_word contains the correct translation
print x # output: hello

you take a slice, but don't store the result of this action anywhere, like demonstrated in the code above.

so in the end, new_world doesn't contain the correct translation


#11

iam so dum you are amazing thank you so much for being so patient with me. :slight_smile:


#12