reversing each word

    0

    0

    Mahendra Kumar

    beginnerstringsreverse

    Python program to reverse each word in a string

    # take inputs
    string = 'Know Program'
    # splitting the string into list of words
    words = string.split(' ')
    # reversing each word and creating a new list of words
    reverseWords = [word[::-1] for word in words]
    # joining the new list of words to for a new string
    reverseString = " ".join(reverseWords)
    # print reverse of each word in a string
    print('The reverse is', reverseString)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.