Write a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the string values in reverse order. The function is to be called from the main method.

Respuesta :

Answer:

Following are the program in python language

def cat_rev(x,y,z): # function definition  

   x=x[::-1]# reverse the first string  

   y=y[::-1]# reverse the second string  

   z=z[::-1]# reverse the third string  

   z=x+y+z;  #concat the string

   return(z)#return the string

   #main method

s=input("Enter the first string:") #read the first string

r=input("Enter the second string:")#Read the second string  

t=input("Enter the third string:")#Read the third string by user

rev1= cat_rev(s,r ,t ) #function calling

print(rev1)# display reverse string

Output:

Enter the first string:san

Enter the second string:ran

Enter the third string:tan

nasnarnat

Explanation:

Following are the description of program

  • In the main function we read the three value by the user in the "s", "r" and "t" variable respectively.
  • After that call the function cat_rev() by pass the variable s,r and t variable in that function .
  • Control moves to the function definition of the cat_rev() function .In this function we reverse the string one by one and concat the string by using + operator .
  • Finally in the main function we print the reverse of the concat string   .