Question: For Python code: # Getting user input as a string and splitting it to list of strings. userInput = input().split() # If user input has
For Python code: # Getting user input as a string and splitting it to list of strings. userInput = input().split() # If user input has three strings then getting firstName, middleName, # and lastName from user entered list of strings. if len(userInput) == 3: firstName = userInput[0] middleName = userInput[1] lastName = userInput[2] # Printing the name in specified format using plus(+) to combine strings. print(lastName+', '+firstName[0]+'.'+middleName[0]+'.') # If user input has two strings only then getting firstName and lastName # from the user entered list of strings elif len(userInput) == 2: firstName = userInput[0] lastName = userInput[1] # Printing the name in specified format using plus(+) to combine to strings. print(lastName+', '+firstName[0]+'.')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
