Given a name, print the initials of a name(uppercase) with last name(with first alphabet in uppercase) written in full separated by dots.
Input : geeks for geeks Output : G.F.Geeks Input : mohandas karamchand gandhi Output : M.K.Gandhi
A naive approach of this will be to iterate for spaces and print the next letter after every space except the last space. At last space we have to take all the characters after the last space in a simple approach.
Using Python in inbuilt functions we can split the words into a list, then traverse till the second last word and print the first character in capitals using upper() function in python and then add the last word using title() function in Python which automatically converts the first alphabet to capital.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to print the initials of a name with the surname
- Program to find the initials of a name.
- numpy.full() in Python
- Python Pytorch full() method
- Full domain Hashing with variable Hash size in Python
- Python end parameter in print()
- How to print without newline in Python?
- Python | sep parameter in print()
- Print with your own font using Python !!
- Print objects of a class in Python
- Print first m multiples of n without using any loop in Python
- Python | Output using print() function
- Pretty Print JSON in Python
- Python | file parameter in print()
- Python | Print Alphabets till N
- Python program to print Emojis
- Print lists in Python (4 Different Ways)
- Print all subsequences of a string in Python
- Python | Print all sublists of a list
- Print Colors in Python terminal
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.