Why does my code work outside but not on codecademy?

I wrote this and it works perfectly in jupyter, but in codecademy i get : ‘string index out of range’

def every_other_letter(word):
    new_string = ''
    for i in range(len(word)):
        if 2*i <= len(word):
            new_string += word[2*i]
    return new_string
1 Like

image

your code works for words of uneven length, not even length

What calls did you attempt in jupyter that do work?

1 Like

it seems like i put only uneven string randomly, haha, but thanks,
have changed for this, works good now:
def every_other_letter(word):
new_string = ‘’
for i in range(len(word)):
if 2i+1 <= len(word):
new_string += word[2
i]
return new_string