In Codewars, question is this: Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.
Examples:
spinWords( "Hey fellow warriors" ) => returns "Hey wollef sroirraw"
spinWords( "This is a test") => returns "This is a test"
spinWords( "This is another test" )=> returns "This is rehtona test
My code is this:
def spin_words(sentence):
splited_string = sentence.split(" ")
empty_string = ""
for char in splited_string:
if len(char) >= 5:
empty_string += char[::-1] + " "
else:
empty_string += char + " "
print(empty_string)
Whenever I test my code on VScode it works perfectly fine.But Codewars didn't accept my code. What is my issue ? Note:I am new at programming and Stackowerflow,If I do something wrong,forgive me.