10. Ending Up


#1

I typed exactly what it told me too but i get a syntax error on len

pyg = 'ay'

original = raw_input('Enter a word:')

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

#2

here:

[1:len(word)]

how is python to know of which string it should take a slice?


#3

It should know to take the slice of variable word because i typed word in parenthesis


#4

no, that is the stop value of the silce. It doesn’t mean it has to take slice of word, i mean what if we only used integers:

[1:5]

how does python know what to take a slice of? Remember how to specify what string/variable containing a string python should take a slice of it?


#5

I think I understand now. Thanks

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
    word = original.lower()
    first = word[0]
    new_word = word[1:] + first + pyg
    print new_word
else:
    print 'empty'

#6