Program to reverse the input phrase using Python


In section our task is to reverse the input phrase.

Program to reverse the input phrase


def phrase_reverse(phrase):

# Split words

    ele = phrase.split(' ')

# Reverse string and join

    rev = ' '.join(reversed(ele))

    return rev


input_string = input("Enter the phrase to reverse: \n")



Program to reverse the input phrase Output


To achieve our task we have firstly split each word from the input phrase using split() function and then joined the reversed words using spaces. The reversed phrase is stored in variable rev and printed on the screen.


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.