Ad
Code
Diff
  • # shuffle = lambda st: " ".join(x[::-1] for x in st.split())
    #
    # 'shuffle()' does the same as 'reverse_word_chars()' below
    
    def reverse_words(s):
        """returns string that is just like s except that the word order is
        reversed."""
        return ' '.join(reversed(s.split()))
    
    def reverse_chars(s):
        """returns string whose char order is mirror image of s """
        return ''.join(reversed(s))
    
    def reverse_word_chars(s):
        """returns string that is just like s except that the letters in each word
        are reversed"""
        return ' '.join(reversed(x) for x in s.split())
    
    • shuffle = lambda st: " ".join(x[::-1] for x in st.split())
    • # shuffle = lambda st: " ".join(x[::-1] for x in st.split())
    • #
    • # 'shuffle()' does the same as 'reverse_word_chars()' below
    • def reverse_words(s):
    • """returns string that is just like s except that the word order is
    • reversed."""
    • return ' '.join(reversed(s.split()))
    • def reverse_chars(s):
    • """returns string whose char order is mirror image of s """
    • return ''.join(reversed(s))
    • def reverse_word_chars(s):
    • """returns string that is just like s except that the letters in each word
    • are reversed"""
    • return ' '.join(reversed(x) for x in s.split())