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
1
Answer:
see this all image
I hope this helps you.
Attachments:
![](https://hi-static.z-dn.net/files/db2/82cbf01a3fe2a29e515a8576f0e95331.jpg)
![](https://hi-static.z-dn.net/files/d46/00a44ba27079c62eaa3ee3895d1739f4.jpg)
![](https://hi-static.z-dn.net/files/df3/263f78e65a0eb3a325bdaa8fa7b95ca9.jpg)
Answered by
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