Answer not accepted for codewards — but my output matches their desired output

This is the kata:

https://www.codewars.com/kata/5264d2b162488dc400000001/train/python

This is my code:

def spin_words(sentence):
sentence_array = sentence.split()
new_array = []
for word in sentence_array:
    if len(word) >=  5:
        word = word[::-1]
        new_array.append(word)
    else:
        new_array.append(word)
new_sentence = ''
for word in new_array:
    new_sentence += word + ' '

return new_sentence

Having trouble figuring out why it isn’t being accepted

Source: Python Questions

LEAVE A COMMENT