Write a program that gets a string containing a person’s first, middle, and last names, and then display their first, middle, and last initials. For example, if the user enters John William Smith the program should display J. W. S.
#Gets a string containing a person’s first, middle, and last names,
#and then display their first, middle, and last initials.
def displayInitials(fullName):
names = fullName.split()
initials = [name[0].upper() + '.' for name in names]
print(' '.join(initials))
# Get the full name from the user
fullName = input("Enter your full name: ")
# Display the initials
displayInitials(fullName)
Executed Output 1:
Enter your full name: John William Smith
J. W. S.
Executed Output 2:
Enter your full name: William Stallings Tony
W. S. T.