Skip to content

Instantly share code, notes, and snippets.

@ilobko
Last active June 4, 2022 17:59
Show Gist options
  • Save ilobko/8ac5a41b5de2e42570d319898ce7ca88 to your computer and use it in GitHub Desktop.
Save ilobko/8ac5a41b5de2e42570d319898ce7ca88 to your computer and use it in GitHub Desktop.
Поменять местами слова в строке из двух слов (“Tom Jerry” → “Jerry Tom”).
# Option 1
def name_shuffler(s):
return ' '.join(s.split(' ')[::-1])
# Option 2
def name_shuffler(s):
return ' '.join(reversed(s.split()))
def name_shuffler(str)
str.split.reverse.join(' ')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment