Created
January 2, 2020 14:33
-
-
Save kkt-ee/799b2b60bdf3c0a76be42ef04efc4f7b to your computer and use it in GitHub Desktop.
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" ) => r…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def spin_words(sentence): | |
# Your code goes here | |
words = sentence.split(' ')#[::-1] | |
newL = list() | |
for word in words: | |
newL.append(word) if len(word)<5 else newL.append(word[::-1]) | |
return ' '.join(newL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment