Last active
June 4, 2022 17:59
-
-
Save ilobko/8ac5a41b5de2e42570d319898ce7ca88 to your computer and use it in GitHub Desktop.
Поменять местами слова в строке из двух слов (“Tom Jerry” → “Jerry Tom”).
This file contains hidden or 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
| # Option 1 | |
| def name_shuffler(s): | |
| return ' '.join(s.split(' ')[::-1]) | |
| # Option 2 | |
| def name_shuffler(s): | |
| return ' '.join(reversed(s.split())) |
This file contains hidden or 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 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