What is wrong with this PygLatin code?


#1



Uploading...


something is wrong with slicing colons. But Idk what is wrong


python'''

Replace this line with your code.
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 (new_word[1:len(new_word)])
else:
print 'empty'
i
`


#2

take all these out.

python does not read lines that are hashtagged, so you can just remove the #.

okay, so you wanna say if x and y:, the format will be(for example), if x > 3 and y > 4:
but you wrote ...........and original.isalpha(): you did not have any equalities linking original.isalpha to a number. You can say, for instance, ................. and original.isalpha() == True:


#3

My code is working. There is something wrong with slicing colons.


#4

hello can i see your full code with proper indentations?

i still dont see the need for these! are these typo?


#5

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

this is full code
and error is
File "python", line 9
new_word = [1:len(new_word)]
^
SyntaxError: invalid syntax


#6

your code is for excercise 10? Ending up?


#7

yes. It for exercise 10.


#9

in this you are slicing twice! you already sliced it in new_word=...... and you are printing the sliced form of new_word sliced. in other words, new_word is sliced 2 times.


#10

yeah!! You are right!!! Thak you!


#11

hello there, consider this solved? mark the post with the solution button! :smile:


#12

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