Computer Science, asked by ppreethika01, 6 months ago

Q-2) Write a Python program which accepts the user's first and last name and print them in reverse order with a
space between them.​

Answers

Answered by ansariishaq324
1

Answer:

see this all image

I hope this helps you.

Attachments:
Answered by SaurabhJacob
0

The python program for the given problem is,

First = input("Enter Your First Name = ")

Last = input("Enter Your Last Name = ")

print("Revers order is",Last[-1::-1],First[-1::-1])

In the above program,

  • The First and Last names are inputted from the user.
  • After that, for printing both the names in reverse order, String Slicing is used and comma(,) is used for the space.

In python programming, negative indexing is also supported. So the slicing is done with a -1 which represents the index of the last character.

After that, it is decreased with the step of -1 for reaching the first character of the word.

Similar questions